Coverage for /root/GitHubProjects/impacket/impacket/dcerpc/v5/dcom/wmi.py: 65%

# Coverage for /root/GitHubProjects/impacket/impacket/dcerpc/v5/dcom/wmi.py : 65%

## 1756 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1# SECUREAUTH LABS. Copyright 2018 SecureAuth Corporation. All rights reserved.

2#

3# This software is provided under under a slightly modified version

4# of the Apache Software License. See the accompanying LICENSE file

5# for more information.

6#

7# Author: Alberto Solino (@agsolino)

8#

9# Description:

10# [MS-WMI]/[MS-WMIO] : Windows Management Instrumentation Remote Protocol. Partial implementation

11#

12# Best way to learn how to use these calls is to grab the protocol standard

13# so you understand what the call does, and then read the test case located

14# at https://github.com/SecureAuthCorp/impacket/tree/master/tests/SMB_RPC

15#

16# Since DCOM is like an OO RPC, instead of helper functions you will see the

17# classes described in the standards developed.

18# There are test cases for them too.

19#

20 from __future__ import division

21 from __future__ import print_function

22 from struct import unpack, calcsize, pack

23 from functools import partial

24 import collections

25 import logging

26

27 from impacket.dcerpc.v5.ndr import NDRSTRUCT, NDRUniConformantArray, NDRPOINTER, NDRUniConformantVaryingArray, NDRUNION, \

28 NDRENUM

29 from impacket.dcerpc.v5.dcomrt import DCOMCALL, DCOMANSWER, IRemUnknown, PMInterfacePointer, INTERFACE, \

30 PMInterfacePointer_ARRAY, BYTE_ARRAY, PPMInterfacePointer, OBJREF_CUSTOM

31 from impacket.dcerpc.v5.dcom.oaut import BSTR

32 from impacket.dcerpc.v5.dtypes import ULONG, DWORD, NULL, LPWSTR, LONG, HRESULT, PGUID, LPCSTR, GUID

33 from impacket.dcerpc.v5.enum import Enum

34 from impacket.dcerpc.v5.rpcrt import DCERPCException

35 from impacket import hresult_errors, LOG

36 from impacket.uuid import string_to_bin, uuidtup_to_bin

37 from impacket.structure import Structure, hexdump

38

39

40 def format_structure(d, level=0):

41 x = ""

42 if isinstance(d, collections.Mapping):

43 lenk = max([len(str(x)) for x in list(d.keys())])

44 for k, v in list(d.items()):

45 key_text = "\n" + " "*level + " "*(lenk - len(str(k))) + str(k)

46 x += key_text + ": " + format_structure(v, level=level+lenk)

47 elif isinstance(d, collections.Iterable) and not isinstance(d, str):

48 for e in d:

49 x += "\n" + " "*level + "- " + format_structure(e, level=level+4)

50 else:

51 x = str(d)

52 return x

53 try:

54 from collections import OrderedDict

55 except:

56 try:

57 from ordereddict.ordereddict import OrderedDict

58 except:

59 from ordereddict import OrderedDict

60

61 class DCERPCSessionError(DCERPCException):

62 def __init__(self, error_string=None, error_code=None, packet=None):

63 DCERPCException.__init__(self, error_string, error_code, packet)

64

65 def __str__( self ):

66 if self.error_code in hresult_errors.ERROR_MESSAGES:

67 error_msg_short = hresult_errors.ERROR_MESSAGES[self.error_code][0]

68 error_msg_verbose = hresult_errors.ERROR_MESSAGES[self.error_code][1]

69 return 'WMI SessionError: code: 0x%x - %s - %s' % (self.error_code, error_msg_short, error_msg_verbose)

70 else:

71 # Let's see if we have it as WBEMSTATUS

72 try:

73 return 'WMI Session Error: code: 0x%x - %s' % (self.error_code, WBEMSTATUS.enumItems(self.error_code).name)

74 except:

75 return 'WMI SessionError: unknown error code: 0x%x' % self.error_code

76

77################################################################################

78# WMIO Structures and Constants

79################################################################################

80 WBEM_FLAVOR_FLAG_PROPAGATE_O_INSTANCE = 0x01

81 WBEM_FLAVOR_FLAG_PROPAGATE_O_DERIVED_CLASS = 0x02

82 WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10

83 WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20

84 WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40

85 WBEM_FLAVOR_AMENDED = 0x80

86

87# 2.2.6 ObjectFlags

88 OBJECT_FLAGS = 'B=0'

89

90#2.2.77 Signature

91 SIGNATURE = '<L=0x12345678'

92

93# 2.2.4 ObjectEncodingLength

94 OBJECT_ENCODING_LENGTH = '<L=0'

95

96# 2.2.73 EncodingLength

97 ENCODING_LENGTH = '<L=0'

98

99# 2.2.78 Encoded-String

100 ENCODED_STRING_FLAG = 'B=0'

101

102# 2.2.76 ReservedOctet

103 RESERVED_OCTET = 'B=0'

104

105# 2.2.28 NdTableValueTableLength

106 NDTABLE_VALUE_TABLE_LENGTH = '<L=0'

107

108# 2.2.80 DictionaryReference

109 DICTIONARY_REFERENCE = {

110 0 : '"',

111 1 : 'key',

112 2 : 'NADA',

113 3 : 'read',

114 4 : 'write',

115 5 : 'volatile',

116 6 : 'provider',

117 7 : 'dynamic',

118 8 : 'cimwin32',

119 9 : 'DWORD',

120 10 : 'CIMTYPE',

121}

122

123 class ENCODED_STRING(Structure):

124 commonHdr = (

125 ('Encoded_String_Flag', ENCODED_STRING_FLAG),

126 )

127

128 tascii = (

129 ('Character', 'z'),

130 )

131

132 tunicode = (

133 ('Character', 'u'),

134 )

135

136 def __init__(self, data = None, alignment = 0):

137 Structure.__init__(self, data, alignment)

138 if data is not None:

139 # Let's first check the commonHdr

140 self.fromString(data)

141 self.structure = ()

142 self.isUnicode = False

143 if len(data) > 1: 143 ↛ exitline 143 didn't return from function '__init__', because the condition on line 143 was never false

144 if self['Encoded_String_Flag'] == 0:

145 self.structure += self.tascii

146 # Let's search for the end of the string

147 index = data[1:].find(b'\x00')

148 data = data[:index+1+1]

149 else:

150 self.structure = self.tunicode

151 self.isUnicode = True

152

153 self.fromString(data)

154 else:

155 self.structure = self.tascii

156 self.data = None

157

158 def __getitem__(self, key):

159 if key == 'Character' and self.isUnicode:

160 return self.fields['Character'].decode('utf-16le')

161 return Structure.__getitem__(self, key)

162

163

164# 2.2.8 DecServerName

165 DEC_SERVER_NAME = ENCODED_STRING

166

167# 2.2.9 DecNamespaceName

168 DEC_NAMESPACE_NAME = ENCODED_STRING

169

170# 2.2.7 Decoration

171 class DECORATION(Structure):

172 structure = (

173 ('DecServerName', ':', DEC_SERVER_NAME),

174 ('DecNamespaceName', ':', DEC_NAMESPACE_NAME),

175 )

176

177# 2.2.69 HeapRef

178 HEAPREF = '<L=0'

179

180# 2.2.68 HeapStringRef

181 HEAP_STRING_REF = HEAPREF

182

183# 2.2.19 ClassNameRef

184 CLASS_NAME_REF = HEAP_STRING_REF

185

186# 2.2.16 ClassHeader

187 class CLASS_HEADER(Structure):

188 structure = (

189 ('EncodingLength', ENCODING_LENGTH),

190 ('ReservedOctet', RESERVED_OCTET),

191 ('ClassNameRef', CLASS_NAME_REF),

192 ('NdTableValueTableLength', NDTABLE_VALUE_TABLE_LENGTH),

193 )

194

195# 2.2.17 DerivationList

196 class DERIVATION_LIST(Structure):

197 structure = (

198 ('EncodingLength', ENCODING_LENGTH),

199 ('_ClassNameEncoding','_-ClassNameEncoding', 'self["EncodingLength"]-4'),

200 ('ClassNameEncoding', ':'),

201 )

202

203# 2.2.82 CimType

204 CIM_TYPE = '<L=0'

205 CIM_ARRAY_FLAG = 0x2000

206

207 class EnumType(type):

208 def __getattr__(self, attr):

209 return self.enumItems[attr].value

210

211 class CIM_TYPE_ENUM(Enum):

212# __metaclass__ = EnumType

213 CIM_TYPE_SINT8 = 16

214 CIM_TYPE_UINT8 = 17

215 CIM_TYPE_SINT16 = 2

216 CIM_TYPE_UINT16 = 18

217 CIM_TYPE_SINT32 = 3

218 CIM_TYPE_UINT32 = 19

219 CIM_TYPE_SINT64 = 20

220 CIM_TYPE_UINT64 = 21

221 CIM_TYPE_REAL32 = 4

222 CIM_TYPE_REAL64 = 5

223 CIM_TYPE_BOOLEAN = 11

224 CIM_TYPE_STRING = 8

225 CIM_TYPE_DATETIME = 101

226 CIM_TYPE_REFERENCE = 102

227 CIM_TYPE_CHAR16 = 103

228 CIM_TYPE_OBJECT = 13

229 CIM_ARRAY_SINT8 = 8208

230 CIM_ARRAY_UINT8 = 8209

231 CIM_ARRAY_SINT16 = 8194

232 CIM_ARRAY_UINT16 = 8210

233 CIM_ARRAY_SINT32 = 8195

234 CIM_ARRAY_UINT32 = 8201

235 CIM_ARRAY_SINT64 = 8202

236 CIM_ARRAY_UINT64 = 8203

237 CIM_ARRAY_REAL32 = 8196

238 CIM_ARRAY_REAL64 = 8197

239 CIM_ARRAY_BOOLEAN = 8203

240 CIM_ARRAY_STRING = 8200

241 CIM_ARRAY_DATETIME = 8293

242 CIM_ARRAY_REFERENCE = 8294

243 CIM_ARRAY_CHAR16 = 8295

244 CIM_ARRAY_OBJECT = 8205

245

246 CIM_TYPES_REF = {

247 CIM_TYPE_ENUM.CIM_TYPE_SINT8.value : 'b=0',

248 CIM_TYPE_ENUM.CIM_TYPE_UINT8.value : 'B=0',

249 CIM_TYPE_ENUM.CIM_TYPE_SINT16.value : '<h=0',

250 CIM_TYPE_ENUM.CIM_TYPE_UINT16.value : '<H=0',

251 CIM_TYPE_ENUM.CIM_TYPE_SINT32.value : '<l=0',

252 CIM_TYPE_ENUM.CIM_TYPE_UINT32.value : '<L=0',

253 CIM_TYPE_ENUM.CIM_TYPE_SINT64.value : '<q=0',

254 CIM_TYPE_ENUM.CIM_TYPE_UINT64.value : '<Q=0',

255 CIM_TYPE_ENUM.CIM_TYPE_REAL32.value : '<f=0',

256 CIM_TYPE_ENUM.CIM_TYPE_REAL64.value : '<d=0',

257 CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value : '<H=0',

258 CIM_TYPE_ENUM.CIM_TYPE_STRING.value : HEAPREF,

259 CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value : HEAPREF,

260 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value: HEAPREF,

261 CIM_TYPE_ENUM.CIM_TYPE_CHAR16.value : '<H=0',

262 CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value : HEAPREF,

263}

264

265 CIM_TYPE_TO_NAME = {

266 CIM_TYPE_ENUM.CIM_TYPE_SINT8.value : 'sint8',

267 CIM_TYPE_ENUM.CIM_TYPE_UINT8.value : 'uint8',

268 CIM_TYPE_ENUM.CIM_TYPE_SINT16.value : 'sint16',

269 CIM_TYPE_ENUM.CIM_TYPE_UINT16.value : 'uint16',

270 CIM_TYPE_ENUM.CIM_TYPE_SINT32.value : 'sint32',

271 CIM_TYPE_ENUM.CIM_TYPE_UINT32.value : 'uint32',

272 CIM_TYPE_ENUM.CIM_TYPE_SINT64.value : 'sint64',

273 CIM_TYPE_ENUM.CIM_TYPE_UINT64.value : 'uint64',

274 CIM_TYPE_ENUM.CIM_TYPE_REAL32.value : 'real32',

275 CIM_TYPE_ENUM.CIM_TYPE_REAL64.value : 'real64',

276 CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value : 'bool',

277 CIM_TYPE_ENUM.CIM_TYPE_STRING.value : 'string',

278 CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value : 'datetime',

279 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value: 'reference',

280 CIM_TYPE_ENUM.CIM_TYPE_CHAR16.value : 'char16',

281 CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value : 'object',

282}

283

284# 2.2.61 QualifierName

285 QUALIFIER_NAME = HEAP_STRING_REF

286

287# 2.2.62 QualifierFlavor

288 QUALIFIER_FLAVOR = 'B=0'

289

290# 2.2.63 QualifierType

291 QUALIFIER_TYPE = CIM_TYPE

292

293# 2.2.71 EncodedValue

294 class ENCODED_VALUE(Structure):

295 structure = (

296 ('QualifierName', QUALIFIER_NAME),

297 )

298

299 @classmethod

300 def getValue(cls, cimType, entry, heap):

301 # Let's get the default Values

302 pType = cimType & (~(CIM_ARRAY_FLAG|Inherited))

303

304 if entry != 0xffffffff: 304 ↛ exitline 304 didn't return from function 'getValue', because the condition on line 304 was never false

305 heapData = heap[entry:]

306 if cimType & CIM_ARRAY_FLAG:

307 # We have an array, let's set the right unpackStr and dataSize for the array contents

308 dataSize = calcsize(HEAPREF[:-2])

309 numItems = unpack(HEAPREF[:-2], heapData[:dataSize])[0]

310 heapData = heapData[dataSize:]

311 array = list()

312 unpackStrArray = CIM_TYPES_REF[pType][:-2]

313 dataSizeArray = calcsize(unpackStrArray)

314 if cimType == CIM_TYPE_ENUM.CIM_ARRAY_STRING.value: 314 ↛ 324line 314 didn't jump to line 324, because the condition on line 314 was never false

315 # We have an array of strings

316 # First items are DWORDs with the string pointers

317 # inside the heap. We don't need those ones

318 heapData = heapData[4*numItems:]

319 # Let's now grab the strings

320 for _ in range(numItems):

321 item = ENCODED_STRING(heapData)

322 array.append(item['Character'])

323 heapData = heapData[len(item.getData()):]

324 elif cimType == CIM_TYPE_ENUM.CIM_ARRAY_OBJECT.value:

325 # Discard the pointers

326 heapData = heapData[dataSize*numItems:]

327 for item in range(numItems):

328 msb = METHOD_SIGNATURE_BLOCK(heapData)

329 unit = ENCODING_UNIT()

330 unit['ObjectEncodingLength'] = msb['EncodingLength']

331 unit['ObjectBlock'] = msb['ObjectBlock']

332 array.append(unit)

333 heapData = heapData[msb['EncodingLength']+4:]

334 else:

335 for item in range(numItems):

336 # ToDo: Learn to unpack the rest of the array of things

337 array.append(unpack(unpackStrArray, heapData[:dataSizeArray])[0])

338 heapData = heapData[dataSizeArray:]

339 value = array

340 elif pType == CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value:

341 if entry == 0xffff: 341 ↛ 344line 341 didn't jump to line 344, because the condition on line 341 was never false

342 value = 'True'

343 else:

344 value = 'False'

345 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value: 345 ↛ 351line 345 didn't jump to line 351, because the condition on line 345 was never true

346 # If the value type is CIM-TYPE-OBJECT, the EncodedValue is a HeapRef to the object encoded as an

347 # ObjectEncodingLength (section 2.2.4) followed by an ObjectBlock (section 2.2.5).

348

349 # ToDo: This is a hack.. We should parse this better. We need to have an ENCODING_UNIT.

350 # I'm going through a METHOD_SIGNATURE_BLOCK first just to parse the ObjectBlock

351 msb = METHOD_SIGNATURE_BLOCK(heapData)

352 unit = ENCODING_UNIT()

353 unit['ObjectEncodingLength'] = msb['EncodingLength']

354 unit['ObjectBlock'] = msb['ObjectBlock']

355 value = unit

356 elif pType not in (CIM_TYPE_ENUM.CIM_TYPE_STRING.value, CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value,

357 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value):

358 value = entry

359 else:

360 try:

361 value = ENCODED_STRING(heapData)['Character']

362 except UnicodeDecodeError:

363 if logging.getLogger().level == logging.DEBUG:

364 LOG.debug('Unicode Error: dumping heapData')

365 hexdump(heapData)

366 raise

367

368 return value

369

370# 2.2.64 QualifierValue

371 QUALIFIER_VALUE = ENCODED_VALUE

372

373# 2.2.60 Qualifier

374 class QUALIFIER(Structure):

375 commonHdr = (

376 ('QualifierName', QUALIFIER_NAME),

377 ('QualifierFlavor', QUALIFIER_FLAVOR),

378 ('QualifierType', QUALIFIER_TYPE),

379 )

380 def __init__(self, data = None, alignment = 0):

381 Structure.__init__(self, data, alignment)

382 if data is not None: 382 ↛ 388line 382 didn't jump to line 388, because the condition on line 382 was never false

383 # Let's first check the commonHdr

384 self.fromString(data)

385 self.structure = (('QualifierValue', CIM_TYPES_REF[self["QualifierType"] & (~CIM_ARRAY_FLAG)]),)

386 self.fromString(data)

387 else:

388 self.data = None

389

390# 2.2.59 QualifierSet

391 class QUALIFIER_SET(Structure):

392 structure = (

393 ('EncodingLength', ENCODING_LENGTH),

394 ('_Qualifier','_-Qualifier', 'self["EncodingLength"]-4'),

395 ('Qualifier', ':'),

396 )

397

398 def getQualifiers(self, heap):

399 data = self['Qualifier']

400 qualifiers = dict()

401 while len(data) > 0:

402 itemn = QUALIFIER(data)

403 if itemn['QualifierName'] == 0xffffffff: 403 ↛ 404line 403 didn't jump to line 404, because the condition on line 403 was never true

404 qName = b''

405 elif itemn['QualifierName'] & 0x80000000:

406 qName = DICTIONARY_REFERENCE[itemn['QualifierName'] & 0x7fffffff]

407 else:

408 qName = ENCODED_STRING(heap[itemn['QualifierName']:])['Character']

409

410 value = ENCODED_VALUE.getValue(itemn['QualifierType'], itemn['QualifierValue'], heap)

411 qualifiers[qName] = value

412 data = data[len(itemn):]

413

414 return qualifiers

415

416# 2.2.20 ClassQualifierSet

417 CLASS_QUALIFIER_SET = QUALIFIER_SET

418

419# 2.2.22 PropertyCount

420 PROPERTY_COUNT = '<L=0'

421

422# 2.2.24 PropertyNameRef

423 PROPERTY_NAME_REF = HEAP_STRING_REF

424

425# 2.2.25 PropertyInfoRef

426 PROPERTY_INFO_REF = HEAPREF

427

428# 2.2.23 PropertyLookup

429 class PropertyLookup(Structure):

430 structure = (

431 ('PropertyNameRef', PROPERTY_NAME_REF),

432 ('PropertyInfoRef', PROPERTY_INFO_REF),

433 )

434

435# 2.2.31 PropertyType

436 PROPERTY_TYPE = '<L=0'

437

438# 2.2.33 DeclarationOrder

439 DECLARATION_ORDER = '<H=0'

440

441# 2.2.34 ValueTableOffset

442 VALUE_TABLE_OFFSET = '<L=0'

443

444# 2.2.35 ClassOfOrigin

445 CLASS_OF_ORIGIN = '<L=0'

446

447# 2.2.36 PropertyQualifierSet

448 PROPERTY_QUALIFIER_SET = QUALIFIER_SET

449

450# 2.2.30 PropertyInfo

451 class PROPERTY_INFO(Structure):

452 structure = (

453 ('PropertyType', PROPERTY_TYPE),

454 ('DeclarationOrder', DECLARATION_ORDER),

455 ('ValueTableOffset', VALUE_TABLE_OFFSET),

456 ('ClassOfOrigin', CLASS_OF_ORIGIN),

457 ('PropertyQualifierSet', ':', PROPERTY_QUALIFIER_SET),

458 )

459

460# 2.2.32 Inherited

461 Inherited = 0x4000

462

463# 2.2.21 PropertyLookupTable

464 class PROPERTY_LOOKUP_TABLE(Structure):

465 PropertyLookupSize = len(PropertyLookup())

466 structure = (

467 ('PropertyCount', PROPERTY_COUNT),

468 ('_PropertyLookup','_-PropertyLookup', 'self["PropertyCount"]*self.PropertyLookupSize'),

469 ('PropertyLookup', ':'),

470 )

471

472 def getProperties(self, heap):

473 propTable = self['PropertyLookup']

474 properties = dict()

475 for property in range(self['PropertyCount']):

476 propItemDict = dict()

477 propItem = PropertyLookup(propTable)

478 if propItem['PropertyNameRef'] & 0x80000000: 478 ↛ 479line 478 didn't jump to line 479, because the condition on line 478 was never true

479 propName = DICTIONARY_REFERENCE[propItem['PropertyNameRef'] & 0x7fffffff]

480 else:

481 propName = ENCODED_STRING(heap[propItem['PropertyNameRef']:])['Character']

482 propInfo = PROPERTY_INFO(heap[propItem['PropertyInfoRef']:])

483 pType = propInfo['PropertyType']

484 pType &= (~CIM_ARRAY_FLAG)

485 pType &= (~Inherited)

486 sType = CIM_TYPE_TO_NAME[pType]

487

488 propItemDict['stype'] = sType

489 propItemDict['name'] = propName

490 propItemDict['type'] = propInfo['PropertyType']

491 propItemDict['order'] = propInfo['DeclarationOrder']

492 propItemDict['inherited'] = propInfo['PropertyType'] & Inherited

493 propItemDict['value'] = None

494

495 qualifiers = dict()

496 qualifiersBuf = propInfo['PropertyQualifierSet']['Qualifier']

497 while len(qualifiersBuf) > 0:

498 record = QUALIFIER(qualifiersBuf)

499 if record['QualifierName'] & 0x80000000:

500 qualifierName = DICTIONARY_REFERENCE[record['QualifierName'] & 0x7fffffff]

501 else:

502 qualifierName = ENCODED_STRING(heap[record['QualifierName']:])['Character']

503 qualifierValue = ENCODED_VALUE.getValue(record['QualifierType'], record['QualifierValue'], heap)

504 qualifiersBuf = qualifiersBuf[len(record):]

505 qualifiers[qualifierName] = qualifierValue

506

507 propItemDict['qualifiers'] = qualifiers

508 properties[propName] = propItemDict

509

510 propTable = propTable[self.PropertyLookupSize:]

511

512 return OrderedDict(sorted(list(properties.items()), key=lambda x: x[1]['order']))

513 #return properties

514

515# 2.2.66 Heap

516 HEAP_LENGTH = '<L=0'

517

518 class HEAP(Structure):

519 structure = (

520 ('HeapLength', HEAP_LENGTH),

521 # HeapLength is a 32-bit value with the most significant bit always set

522 # (using little-endian binary encoding for the 32-bit value), so that the

523 # length is actually only 31 bits.

524 ('_HeapItem','_-HeapItem', 'self["HeapLength"]&0x7fffffff'),

525 ('HeapItem', ':'),

526 )

527

528# 2.2.37 ClassHeap

529 CLASS_HEAP = HEAP

530

531# 2.2.15 ClassPart

532 class CLASS_PART(Structure):

533 commonHdr = (

534 ('ClassHeader', ':', CLASS_HEADER),

535 ('DerivationList', ':', DERIVATION_LIST),

536 ('ClassQualifierSet', ':', CLASS_QUALIFIER_SET),

537 ('PropertyLookupTable', ':', PROPERTY_LOOKUP_TABLE),

538 ('_NdTable_ValueTable','_-NdTable_ValueTable', 'self["ClassHeader"]["NdTableValueTableLength"]'),

539 ('NdTable_ValueTable',':'),

540 ('ClassHeap', ':', CLASS_HEAP),

541 ('_Garbage', '_-Garbage', 'self["ClassHeader"]["EncodingLength"]-len(self)'),

542 ('Garbage', ':=b""'),

543 )

544 def getQualifiers(self):

545 return self["ClassQualifierSet"].getQualifiers(self["ClassHeap"]["HeapItem"])

546

547 def getProperties(self):

548 heap = self["ClassHeap"]["HeapItem"]

549 properties = self["PropertyLookupTable"].getProperties(self["ClassHeap"]["HeapItem"])

550 sorted_props = sorted(list(properties.keys()), key=lambda k: properties[k]['order'])

551 valueTableOff = (len(properties) - 1) // 4 + 1

552 valueTable = self['NdTable_ValueTable'][valueTableOff:]

553 for key in sorted_props:

554 # Let's get the default Values

555 pType = properties[key]['type'] & (~(CIM_ARRAY_FLAG|Inherited))

556 if properties[key]['type'] & CIM_ARRAY_FLAG: 556 ↛ 557line 556 didn't jump to line 557, because the condition on line 556 was never true

557 unpackStr = HEAPREF[:-2]

558 else:

559 unpackStr = CIM_TYPES_REF[pType][:-2]

560 dataSize = calcsize(unpackStr)

561 try:

562 itemValue = unpack(unpackStr, valueTable[:dataSize])[0]

563 except:

564 LOG.error("getProperties: Error unpacking!!")

565 itemValue = 0xffffffff

566

567 if itemValue != 0xffffffff and itemValue > 0:

568 value = ENCODED_VALUE.getValue(properties[key]['type'], itemValue, heap)

569 properties[key]['value'] = "%s" % value

570 valueTable = valueTable[dataSize:]

571 return properties

572

573# 2.2.39 MethodCount

574 METHOD_COUNT = '<H=0'

575

576# 2.2.40 MethodCountPadding

577 METHOD_COUNT_PADDING = '<H=0'

578

579# 2.2.42 MethodName

580 METHOD_NAME = HEAP_STRING_REF

581

582# 2.2.43 MethodFlags

583 METHOD_FLAGS = 'B=0'

584

585# 2.2.44 MethodPadding

586 METHOD_PADDING = "3s=b''"

587

588# 2.2.45 MethodOrigin

589 METHOD_ORIGIN = '<L=0'

590

591# 2.2.47 HeapQualifierSetRef

592 HEAP_QUALIFIER_SET_REF = HEAPREF

593

594# 2.2.46 MethodQualifiers

595 METHOD_QUALIFIERS = HEAP_QUALIFIER_SET_REF

596

597# 2.2.51 HeapMethodSignatureBlockRef

598 HEAP_METHOD_SIGNATURE_BLOCK_REF = HEAPREF

599

600# 2.2.50 MethodSignature

601 METHOD_SIGNATURE = HEAP_METHOD_SIGNATURE_BLOCK_REF

602

603# 2.2.48 InputSignature

604 INPUT_SIGNATURE = METHOD_SIGNATURE

605

606# 2.2.49 OutputSignature

607 OUTPUT_SIGNATURE = METHOD_SIGNATURE

608

609# 2.2.52 MethodHeap

610 METHOD_HEAP = HEAP

611

612# 2.2.41 MethodDescription

613 class METHOD_DESCRIPTION(Structure):

614 structure = (

615 ('MethodName',METHOD_NAME),

616 ('MethodFlags', METHOD_FLAGS),

617 ('MethodPadding', METHOD_PADDING),

618 ('MethodOrigin', METHOD_ORIGIN),

619 ('MethodQualifiers', METHOD_QUALIFIERS),

620 ('InputSignature', INPUT_SIGNATURE),

621 ('OutputSignature', OUTPUT_SIGNATURE),

622 )

623

624# 2.2.38 MethodsPart

625 class METHODS_PART(Structure):

626 MethodDescriptionSize = len(METHOD_DESCRIPTION())

627 structure = (

628 ('EncodingLength',ENCODING_LENGTH),

629 ('MethodCount', METHOD_COUNT),

630 ('MethodCountPadding', METHOD_COUNT_PADDING),

631 ('_MethodDescription', '_-MethodDescription', 'self["MethodCount"]*self.MethodDescriptionSize'),

632 ('MethodDescription', ':'),

633 ('MethodHeap', ':', METHOD_HEAP),

634 )

635

636 def getMethods(self):

637 methods = OrderedDict()

638 data = self['MethodDescription']

639 heap = self['MethodHeap']['HeapItem']

640

641 for method in range(self['MethodCount']):

642 methodDict = OrderedDict()

643 itemn = METHOD_DESCRIPTION(data)

644 if itemn['MethodFlags'] & WBEM_FLAVOR_ORIGIN_PROPAGATED:

645 # ToDo

646 #print "WBEM_FLAVOR_ORIGIN_PROPAGATED not yet supported!"

647 #raise

648 pass

649 methodDict['name'] = ENCODED_STRING(heap[itemn['MethodName']:])['Character']

650 methodDict['origin'] = itemn['MethodOrigin']

651 if itemn['MethodQualifiers'] != 0xffffffff: 651 ↛ 656line 651 didn't jump to line 656, because the condition on line 651 was never false

652 # There are qualifiers

653 qualifiersSet = QUALIFIER_SET(heap[itemn['MethodQualifiers']:])

654 qualifiers = qualifiersSet.getQualifiers(heap)

655 methodDict['qualifiers'] = qualifiers

656 if itemn['InputSignature'] != 0xffffffff: 656 ↛ 664line 656 didn't jump to line 664, because the condition on line 656 was never false

657 inputSignature = METHOD_SIGNATURE_BLOCK(heap[itemn['InputSignature']:])

658 if inputSignature['EncodingLength'] > 0:

659 methodDict['InParams'] = inputSignature['ObjectBlock']['ClassType']['CurrentClass'].getProperties()

660 methodDict['InParamsRaw'] = inputSignature['ObjectBlock']

661 #print methodDict['InParams']

662 else:

663 methodDict['InParams'] = None

664 if itemn['OutputSignature'] != 0xffffffff: 664 ↛ 671line 664 didn't jump to line 671, because the condition on line 664 was never false

665 outputSignature = METHOD_SIGNATURE_BLOCK(heap[itemn['OutputSignature']:])

666 if outputSignature['EncodingLength'] > 0: 666 ↛ 670line 666 didn't jump to line 670, because the condition on line 666 was never false

667 methodDict['OutParams'] = outputSignature['ObjectBlock']['ClassType']['CurrentClass'].getProperties()

668 methodDict['OutParamsRaw'] = outputSignature['ObjectBlock']

669 else:

670 methodDict['OutParams'] = None

671 data = data[len(itemn):]

672 methods[methodDict['name']] = methodDict

673

674 return methods

675

676# 2.2.14 ClassAndMethodsPart

677 class CLASS_AND_METHODS_PART(Structure):

678 structure = (

679 ('ClassPart', ':', CLASS_PART),

680 ('MethodsPart', ':', METHODS_PART),

681 )

682

683 def getClassName(self):

684 pClassName = self['ClassPart']['ClassHeader']['ClassNameRef']

685 cHeap = self['ClassPart']['ClassHeap']['HeapItem']

686 if pClassName == 0xffffffff: 686 ↛ 687line 686 didn't jump to line 687, because the condition on line 686 was never true

687 return 'None'

688 else:

689 className = ENCODED_STRING(cHeap[pClassName:])['Character']

690 derivationList = self['ClassPart']['DerivationList']['ClassNameEncoding']

691 while len(derivationList) > 0:

692 superClass = ENCODED_STRING(derivationList)['Character']

693 className += ' : %s ' % superClass

694 derivationList = derivationList[len(ENCODED_STRING(derivationList))+4:]

695 return className

696

697 def getQualifiers(self):

698 return self["ClassPart"].getQualifiers()

699

700 def getProperties(self):

701 #print format_structure(self["ClassPart"].getProperties())

702 return self["ClassPart"].getProperties()

703

704 def getMethods(self):

705 return self["MethodsPart"].getMethods()

706

707# 2.2.13 CurrentClass

708 CURRENT_CLASS = CLASS_AND_METHODS_PART

709

710# 2.2.54 InstanceFlags

711 INSTANCE_FLAGS = 'B=0'

712

713# 2.2.55 InstanceClassName

714 INSTANCE_CLASS_NAME = HEAP_STRING_REF

715

716# 2.2.27 NullAndDefaultFlag

717 NULL_AND_DEFAULT_FLAG = 'B=0'

718

719# 2.2.26 NdTable

720 NDTABLE = NULL_AND_DEFAULT_FLAG

721

722# 2.2.56 InstanceData

723#InstanceData = ValueTable

724

725 class CURRENT_CLASS_NO_METHODS(CLASS_AND_METHODS_PART):

726 structure = (

727 ('ClassPart', ':', CLASS_PART),

728 )

729 def getMethods(self):

730 return ()

731

732# 2.2.65 InstancePropQualifierSet

733 INST_PROP_QUAL_SET_FLAG = 'B=0'

734 class INSTANCE_PROP_QUALIFIER_SET(Structure):

735 commonHdr = (

736 ('InstPropQualSetFlag', INST_PROP_QUAL_SET_FLAG),

737 )

738 tail = (

739 # ToDo: this is wrong.. this should be an array of QualifierSet, see documentation

740 #('QualifierSet', ':', QualifierSet),

741 ('QualifierSet', ':', QUALIFIER_SET),

742 )

743

744 def __init__(self, data = None, alignment = 0):

745 Structure.__init__(self, data, alignment)

746 self.structure = ()

747 if data is not None: 747 ↛ 755line 747 didn't jump to line 755, because the condition on line 747 was never false

748 # Let's first check the commonHdr

749 self.fromString(data)

750 if self['InstPropQualSetFlag'] == 2: 750 ↛ 752line 750 didn't jump to line 752, because the condition on line 750 was never true

751 # We don't support this yet!

752 raise Exception("self['InstPropQualSetFlag'] == 2")

753 self.fromString(data)

754 else:

755 self.data = None

756

757# 2.2.57 InstanceQualifierSet

758 class INSTANCE_QUALIFIER_SET(Structure):

759 structure = (

760 ('QualifierSet', ':', QUALIFIER_SET),

761 ('InstancePropQualifierSet', ':', INSTANCE_PROP_QUALIFIER_SET),

762 )

763

764# 2.2.58 InstanceHeap

765 INSTANCE_HEAP = HEAP

766

767# 2.2.53 InstanceType

768 class INSTANCE_TYPE(Structure):

769 commonHdr = (

770 ('CurrentClass', ':', CURRENT_CLASS_NO_METHODS),

771 ('EncodingLength', ENCODING_LENGTH),

772 ('InstanceFlags', INSTANCE_FLAGS),

773 ('InstanceClassName', INSTANCE_CLASS_NAME),

774 ('_NdTable_ValueTable', '_-NdTable_ValueTable',

775 'self["CurrentClass"]["ClassPart"]["ClassHeader"]["NdTableValueTableLength"]'),

776 ('NdTable_ValueTable',':'),

777 ('InstanceQualifierSet', ':', INSTANCE_QUALIFIER_SET),

778 ('InstanceHeap', ':', INSTANCE_HEAP),

779 )

780

781 def __init__(self, data = None, alignment = 0):

782 Structure.__init__(self, data, alignment)

783 self.structure = ()

784 if data is not None:

785 # Let's first check the commonHdr

786 self.fromString(data)

787 #hexdump(data[len(self.getData()):])

788 self.NdTableSize = (self['CurrentClass']['ClassPart']['PropertyLookupTable']['PropertyCount'] - 1) //4 + 1

789 #self.InstanceDataSize = self['CurrentClass']['ClassPart']['PropertyLookupTable']['PropertyCount'] * len(InstanceData())

790 self.fromString(data)

791 else:

792 self.data = None

793

794 def getValues(self, properties):

795 heap = self["InstanceHeap"]["HeapItem"]

796 valueTableOff = (len(properties) - 1) // 4 + 1

797 valueTable = self['NdTable_ValueTable'][valueTableOff:]

798 sorted_props = sorted(list(properties.keys()), key=lambda k: properties[k]['order'])

799 for key in sorted_props:

800 pType = properties[key]['type'] & (~(CIM_ARRAY_FLAG|Inherited))

801 if properties[key]['type'] & CIM_ARRAY_FLAG: 801 ↛ 802line 801 didn't jump to line 802, because the condition on line 801 was never true

802 unpackStr = HEAPREF[:-2]

803 else:

804 unpackStr = CIM_TYPES_REF[pType][:-2]

805 dataSize = calcsize(unpackStr)

806 try:

807 itemValue = unpack(unpackStr, valueTable[:dataSize])[0]

808 except:

809 LOG.error("getValues: Error Unpacking!")

810 itemValue = 0xffffffff

811

812 # if itemValue == 0, default value remains

813 if itemValue != 0:

814 value = ENCODED_VALUE.getValue( properties[key]['type'], itemValue, heap)

815 properties[key]['value'] = value

816 # is the value set valid or should we clear it? ( if not inherited )

817 elif properties[key]['inherited'] == 0:

818 properties[key]['value'] = None

819 valueTable = valueTable[dataSize:]

820 return properties

821

822# 2.2.12 ParentClass

823 PARENT_CLASS = CLASS_AND_METHODS_PART

824

825# 2.2.13 CurrentClass

826 CURRENT_CLASS = CLASS_AND_METHODS_PART

827

828 class CLASS_TYPE(Structure):

829 structure = (

830 ('ParentClass', ':', PARENT_CLASS),

831 ('CurrentClass', ':', CURRENT_CLASS),

832 )

833

834# 2.2.5 ObjectBlock

835 class OBJECT_BLOCK(Structure):

836 commonHdr = (

837 ('ObjectFlags', OBJECT_FLAGS),

838 )

839

840 decoration = (

841 ('Decoration', ':', DECORATION),

842 )

843

844 instanceType = (

845 ('InstanceType', ':', INSTANCE_TYPE),

846 )

847

848 classType = (

849 ('ClassType', ':', CLASS_TYPE),

850 )

851 def __init__(self, data = None, alignment = 0):

852 Structure.__init__(self, data, alignment)

853 self.ctParent = None

854 self.ctCurrent = None

855

856 if data is not None:

857 self.structure = ()

858 if ord(data[0:1]) & 0x4:

859 # WMIO - 2.2.6 - 0x04 If this flag is set, the object has a Decoration block.

860 self.structure += self.decoration

861 if ord(data[0:1]) & 0x01:

862 # The object is a CIM class.

863 self.structure += self.classType

864 else:

865 self.structure += self.instanceType

866

867 self.fromString(data)

868 else:

869 self.data = None

870

871 def isInstance(self):

872 if self['ObjectFlags'] & 0x01:

873 return False

874 return True

875

876 def printClass(self, pClass, cInstance = None):

877 qualifiers = pClass.getQualifiers()

878

879 for qualifier in qualifiers:

880 print("[%s]" % qualifier)

881

882 className = pClass.getClassName()

883

884 print("class %s \n{" % className)

885

886 properties = pClass.getProperties()

887 if cInstance is not None:

888 properties = cInstance.getValues(properties)

889

890 for pName in properties:

891 #if property['inherited'] == 0:

892 qualifiers = properties[pName]['qualifiers']

893 for qName in qualifiers:

894 if qName != 'CIMTYPE':

895 print('\t[%s(%s)]' % (qName, qualifiers[qName]))

896 print("\t%s %s" % (properties[pName]['stype'], properties[pName]['name']), end=' ')

897 if properties[pName]['value'] is not None:

898 if properties[pName]['type'] == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

899 print('= IWbemClassObject\n')

900 elif properties[pName]['type'] == CIM_TYPE_ENUM.CIM_ARRAY_OBJECT.value:

901 if properties[pName]['value'] == 0:

902 print('= %s\n' % properties[pName]['value'])

903 else:

904 print('= %s\n' % list('IWbemClassObject' for _ in range(len(properties[pName]['value']))))

905 else:

906 print('= %s\n' % properties[pName]['value'])

907 else:

908 print('\n')

909

910 print()

911 methods = pClass.getMethods()

912 for methodName in methods:

913 for qualifier in methods[methodName]['qualifiers']:

914 print('\t[%s]' % qualifier)

915

916 if methods[methodName]['InParams'] is None and methods[methodName]['OutParams'] is None:

917 print('\t%s %s();\n' % ('void', methodName))

918 if methods[methodName]['InParams'] is None and len(methods[methodName]['OutParams']) == 1:

919 print('\t%s %s();\n' % (methods[methodName]['OutParams']['ReturnValue']['stype'], methodName))

920 else:

921 returnValue = b''

922 if methods[methodName]['OutParams'] is not None:

923 # Search the Return Value

924 #returnValue = (item for item in method['OutParams'] if item["name"] == "ReturnValue").next()

925 if 'ReturnValue' in methods[methodName]['OutParams']:

926 returnValue = methods[methodName]['OutParams']['ReturnValue']['stype']

927

928 print('\t%s %s(\n' % (returnValue, methodName), end=' ')

929 if methods[methodName]['InParams'] is not None:

930 for pName in methods[methodName]['InParams']:

931 print('\t\t[in] %s %s,' % (methods[methodName]['InParams'][pName]['stype'], pName))

932

933 if methods[methodName]['OutParams'] is not None:

934 for pName in methods[methodName]['OutParams']:

935 if pName != 'ReturnValue':

936 print('\t\t[out] %s %s,' % (methods[methodName]['OutParams'][pName]['stype'], pName))

937

938 print('\t);\n')

939

940 print("}")

941

942 def parseClass(self, pClass, cInstance = None):

943 classDict = OrderedDict()

944 classDict['name'] = pClass.getClassName()

945 classDict['qualifiers'] = pClass.getQualifiers()

946 classDict['properties'] = pClass.getProperties()

947 classDict['methods'] = pClass.getMethods()

948 if cInstance is not None:

949 classDict['values'] = cInstance.getValues(classDict['properties'])

950 else:

951 classDict['values'] = None

952

953 return classDict

954

955 def parseObject(self):

956 if (self['ObjectFlags'] & 0x01) == 0:

957 # instance

958 ctCurrent = self['InstanceType']['CurrentClass']

959 currentName = ctCurrent.getClassName()

960 if currentName is not None: 960 ↛ 962line 960 didn't jump to line 962, because the condition on line 960 was never false

961 self.ctCurrent = self.parseClass(ctCurrent, self['InstanceType'])

962 return

963 else:

964 ctParent = self['ClassType']['ParentClass']

965 ctCurrent = self['ClassType']['CurrentClass']

966

967 parentName = ctParent.getClassName()

968 if parentName is not None: 968 ↛ 971line 968 didn't jump to line 971, because the condition on line 968 was never false

969 self.ctParent = self.parseClass(ctParent)

970

971 currentName = ctCurrent.getClassName()

972 if currentName is not None: 972 ↛ exitline 972 didn't return from function 'parseObject', because the condition on line 972 was never false

973 self.ctCurrent = self.parseClass(ctCurrent)

974

975 def printInformation(self):

976 # First off, do we have a class?

977 if (self['ObjectFlags'] & 0x01) == 0:

978 # instance

979 ctCurrent = self['InstanceType']['CurrentClass']

980 currentName = ctCurrent.getClassName()

981 if currentName is not None:

982 self.printClass(ctCurrent, self['InstanceType'])

983 return

984 else:

985 ctParent = self['ClassType']['ParentClass']

986 ctCurrent = self['ClassType']['CurrentClass']

987

988 parentName = ctParent.getClassName()

989 if parentName is not None:

990 self.printClass(ctParent)

991

992 currentName = ctCurrent.getClassName()

993 if currentName is not None:

994 self.printClass(ctCurrent)

995

996# 2.2.70 MethodSignatureBlock

997 class METHOD_SIGNATURE_BLOCK(Structure):

998 commonHdr = (

999 ('EncodingLength', ENCODING_LENGTH),

1000 )

1001 tail = (

1002 ('_ObjectBlock', '_-ObjectBlock', 'self["EncodingLength"]'),

1003 ('ObjectBlock', ':', OBJECT_BLOCK),

1004 )

1005 def __init__(self, data = None, alignment = 0):

1006 Structure.__init__(self, data, alignment)

1007 if data is not None: 1007 ↛ 1014line 1007 didn't jump to line 1014, because the condition on line 1007 was never false

1008 self.fromString(data)

1009 if self['EncodingLength'] > 0:

1010 self.structure = ()

1011 self.structure += self.tail

1012 self.fromString(data)

1013 else:

1014 self.data = None

1015

1016# 2.2.1 EncodingUnit

1017 class ENCODING_UNIT(Structure):

1018 structure = (

1019 ('Signature', SIGNATURE),

1020 ('ObjectEncodingLength', OBJECT_ENCODING_LENGTH),

1021 ('_ObjectBlock', '_-ObjectBlock', 'self["ObjectEncodingLength"]'),

1022 ('ObjectBlock', ':', OBJECT_BLOCK),

1023 )

1024

1025################################################################################

1026# CONSTANTS

1027################################################################################

1028# 1.9 Standards Assignments

1029 CLSID_WbemLevel1Login = string_to_bin('8BC3F05E-D86B-11D0-A075-00C04FB68820')

1030 CLSID_WbemBackupRestore = string_to_bin('C49E32C6-BC8B-11D2-85D4-00105A1F8304')

1031 CLSID_WbemClassObject = string_to_bin('4590F812-1D3A-11D0-891F-00AA004B2E24')

1032

1033 IID_IWbemLevel1Login = uuidtup_to_bin(('F309AD18-D86A-11d0-A075-00C04FB68820', '0.0'))

1034 IID_IWbemLoginClientID = uuidtup_to_bin(('d4781cd6-e5d3-44df-ad94-930efe48a887', '0.0'))

1035 IID_IWbemLoginHelper = uuidtup_to_bin(('541679AB-2E5F-11d3-B34E-00104BCC4B4A', '0.0'))

1036 IID_IWbemServices = uuidtup_to_bin(('9556DC99-828C-11CF-A37E-00AA003240C7', '0.0'))

1037 IID_IWbemBackupRestore = uuidtup_to_bin(('C49E32C7-BC8B-11d2-85D4-00105A1F8304', '0.0'))

1038 IID_IWbemBackupRestoreEx = uuidtup_to_bin(('A359DEC5-E813-4834-8A2A-BA7F1D777D76', '0.0'))

1039 IID_IWbemClassObject = uuidtup_to_bin(('DC12A681-737F-11CF-884D-00AA004B2E24', '0.0'))

1040 IID_IWbemContext = uuidtup_to_bin(('44aca674-e8fc-11d0-a07c-00c04fb68820', '0.0'))

1041 IID_IEnumWbemClassObject = uuidtup_to_bin(('027947e1-d731-11ce-a357-000000000001', '0.0'))

1042 IID_IWbemCallResult = uuidtup_to_bin(('44aca675-e8fc-11d0-a07c-00c04fb68820', '0.0'))

1043 IID_IWbemFetchSmartEnum = uuidtup_to_bin(('1C1C45EE-4395-11d2-B60B-00104B703EFD', '0.0'))

1044 IID_IWbemWCOSmartEnum = uuidtup_to_bin(('423EC01E-2E35-11d2-B604-00104B703EFD', '0.0'))

1045

1046 error_status_t = ULONG

1047

1048# lFlags

1049 WBEM_FLAG_RETURN_WBEM_COMPLETE = 0x00000000

1050 WBEM_FLAG_UPDATE_ONLY = 0x00000001

1051 WBEM_FLAG_CREATE_ONLY = 0x00000002

1052 WBEM_FLAG_RETURN_IMMEDIATELY = 0x00000010

1053 WBEM_FLAG_UPDATE_SAFE_MODE = 0x00000020

1054 WBEM_FLAG_FORWARD_ONLY = 0x00000020

1055 WBEM_FLAG_NO_ERROR_OBJECT = 0x00000040

1056 WBEM_FLAG_UPDATE_FORCE_MODE = 0x00000040

1057 WBEM_FLAG_SEND_STATUS = 0x00000080

1058 WBEM_FLAG_ENSURE_LOCATABLE = 0x00000100

1059 WBEM_FLAG_DIRECT_READ = 0x00000200

1060 WBEM_MASK_RESERVED_FLAGS = 0x0001F000

1061 WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x00020000

1062 WBEM_FLAG_STRONG_VALIDATION = 0x00100000

1063 WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN = 0x00000001

1064

1065 WBEM_INFINITE = 0xffffffff

1066

1067################################################################################

1068# STRUCTURES

1069################################################################################

1070 class UCHAR_ARRAY_CV(NDRUniConformantVaryingArray):

1071 item = 'c'

1072

1073 class PUCHAR_ARRAY_CV(NDRPOINTER):

1074 referent = (

1075 ('Data', UCHAR_ARRAY_CV),

1076 )

1077

1078 class PMInterfacePointer_ARRAY_CV(NDRUniConformantVaryingArray):

1079 item = PMInterfacePointer

1080

1081 REFGUID = PGUID

1082

1083 class ULONG_ARRAY(NDRUniConformantArray):

1084 item = ULONG

1085

1086 class PULONG_ARRAY(NDRPOINTER):

1087 referent = (

1088 ('Data', ULONG_ARRAY),

1089 )

1090

1091# 2.2.5 WBEM_CHANGE_FLAG_TYPE Enumeration

1092 class WBEM_CHANGE_FLAG_TYPE(NDRENUM):

1093 # [v1_enum] type

1094 structure = (

1095 ('Data', '<L'),

1096 )

1097 class enumItems(Enum):

1098 WBEM_FLAG_CREATE_OR_UPDATE = 0x00

1099 WBEM_FLAG_UPDATE_ONLY = 0x01

1100 WBEM_FLAG_CREATE_ONLY = 0x02

1101 WBEM_FLAG_UPDATE_SAFE_MODE = 0x20

1102 WBEM_FLAG_UPDATE_FORCE_MODE = 0x40

1103

1104# 2.2.6 WBEM_GENERIC_FLAG_TYPE Enumeration

1105 class WBEM_GENERIC_FLAG_TYPE(NDRENUM):

1106 # [v1_enum] type

1107 structure = (

1108 ('Data', '<L'),

1109 )

1110 class enumItems(Enum):

1111 WBEM_FLAG_RETURN_WBEM_COMPLETE = 0x00

1112 WBEM_FLAG_RETURN_IMMEDIATELY = 0x10

1113 WBEM_FLAG_FORWARD_ONLY = 0x20

1114 WBEM_FLAG_NO_ERROR_OBJECT = 0x40

1115 WBEM_FLAG_SEND_STATUS = 0x80

1116 WBEM_FLAG_ENSURE_LOCATABLE = 0x100

1117 WBEM_FLAG_DIRECT_READ = 0x200

1118 WBEM_MASK_RESERVED_FLAGS = 0x1F000

1119 WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000

1120 WBEM_FLAG_STRONG_VALIDATION = 0x100000

1121

1122# 2.2.7 WBEM_STATUS_TYPE Enumeration

1123 class WBEM_STATUS_TYPE(NDRENUM):

1124 class enumItems(Enum):

1125 WBEM_STATUS_COMPLETE = 0x00

1126 WBEM_STATUS_REQUIREMENTS = 0x01

1127 WBEM_STATUS_PROGRESS = 0x02

1128

1129# 2.2.8 WBEM_TIMEOUT_TYPE Enumeration

1130 class WBEM_TIMEOUT_TYPE(NDRENUM):

1131 # [v1_enum] type

1132 structure = (

1133 ('Data', '<L'),

1134 )

1135 class enumItems(Enum):

1136 WBEM_NO_WAIT = 0x00000000

1137 WBEM_INFINITE = 0xFFFFFFFF

1138

1139# 2.2.9 WBEM_QUERY_FLAG_TYPE Enumeration

1140 class WBEM_QUERY_FLAG_TYPE(NDRENUM):

1141 # [v1_enum] type

1142 structure = (

1143 ('Data', '<L'),

1144 )

1145 class enumItems(Enum):

1146 WBEM_FLAG_DEEP = 0x00000000

1147 WBEM_FLAG_SHALLOW = 0x00000001

1148 WBEM_FLAG_PROTOTYPE = 0x00000002

1149

1150# 2.2.10 WBEM_BACKUP_RESTORE_FLAGS Enumeration

1151 class WBEM_BACKUP_RESTORE_FLAGS(NDRENUM):

1152 # [v1_enum] type

1153 structure = (

1154 ('Data', '<L'),

1155 )

1156 class enumItems(Enum):

1157 WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN = 0x00000001

1158

1159# 2.2.11 WBEMSTATUS Enumeration

1160 class WBEMSTATUS(NDRENUM):

1161 # [v1_enum] type

1162 structure = (

1163 ('Data', '<L'),

1164 )

1165 class enumItems(Enum):

1166 WBEM_S_NO_ERROR = 0x00000000

1167 WBEM_S_FALSE = 0x00000001

1168 WBEM_S_TIMEDOUT = 0x00040004

1169 WBEM_S_NEW_STYLE = 0x000400FF

1170 WBEM_S_PARTIAL_RESULTS = 0x00040010

1171 WBEM_E_FAILED = 0x80041001

1172 WBEM_E_NOT_FOUND = 0x80041002

1173 WBEM_E_ACCESS_DENIED = 0x80041003

1174 WBEM_E_PROVIDER_FAILURE = 0x80041004

1175 WBEM_E_TYPE_MISMATCH = 0x80041005

1176 WBEM_E_OUT_OF_MEMORY = 0x80041006

1177 WBEM_E_INVALID_CONTEXT = 0x80041007

1178 WBEM_E_INVALID_PARAMETER = 0x80041008

1179 WBEM_E_NOT_AVAILABLE = 0x80041009

1180 WBEM_E_CRITICAL_ERROR = 0x8004100a

1181 WBEM_E_NOT_SUPPORTED = 0x8004100c

1182 WBEM_E_PROVIDER_NOT_FOUND = 0x80041011

1183 WBEM_E_INVALID_PROVIDER_REGISTRATION = 0x80041012

1184 WBEM_E_PROVIDER_LOAD_FAILURE = 0x80041013

1185 WBEM_E_INITIALIZATION_FAILURE = 0x80041014

1186 WBEM_E_TRANSPORT_FAILURE = 0x80041015

1187 WBEM_E_INVALID_OPERATION = 0x80041016

1188 WBEM_E_ALREADY_EXISTS = 0x80041019

1189 WBEM_E_UNEXPECTED = 0x8004101d

1190 WBEM_E_INCOMPLETE_CLASS = 0x80041020

1191 WBEM_E_SHUTTING_DOWN = 0x80041033

1192 E_NOTIMPL = 0x80004001

1193 WBEM_E_INVALID_SUPERCLASS = 0x8004100D

1194 WBEM_E_INVALID_NAMESPACE = 0x8004100E

1195 WBEM_E_INVALID_OBJECT = 0x8004100F

1196 WBEM_E_INVALID_CLASS = 0x80041010

1197 WBEM_E_INVALID_QUERY = 0x80041017

1198 WBEM_E_INVALID_QUERY_TYPE = 0x80041018

1199 WBEM_E_PROVIDER_NOT_CAPABLE = 0x80041024

1200 WBEM_E_CLASS_HAS_CHILDREN = 0x80041025

1201 WBEM_E_CLASS_HAS_INSTANCES = 0x80041026

1202 WBEM_E_ILLEGAL_NULL = 0x80041028

1203 WBEM_E_INVALID_CIM_TYPE = 0x8004102D

1204 WBEM_E_INVALID_METHOD = 0x8004102E

1205 WBEM_E_INVALID_METHOD_PARAMETERS = 0x8004102F

1206 WBEM_E_INVALID_PROPERTY = 0x80041031

1207 WBEM_E_CALL_CANCELLED = 0x80041032

1208 WBEM_E_INVALID_OBJECT_PATH = 0x8004103A

1209 WBEM_E_OUT_OF_DISK_SPACE = 0x8004103B

1210 WBEM_E_UNSUPPORTED_PUT_EXTENSION = 0x8004103D

1211 WBEM_E_QUOTA_VIOLATION = 0x8004106c

1212 WBEM_E_SERVER_TOO_BUSY = 0x80041045

1213 WBEM_E_METHOD_NOT_IMPLEMENTED = 0x80041055

1214 WBEM_E_METHOD_DISABLED = 0x80041056

1215 WBEM_E_UNPARSABLE_QUERY = 0x80041058

1216 WBEM_E_NOT_EVENT_CLASS = 0x80041059

1217 WBEM_E_MISSING_GROUP_WITHIN = 0x8004105A

1218 WBEM_E_MISSING_AGGREGATION_LIST = 0x8004105B

1219 WBEM_E_PROPERTY_NOT_AN_OBJECT = 0x8004105c

1220 WBEM_E_AGGREGATING_BY_OBJECT = 0x8004105d

1221 WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING= 0x80041060

1222 WBEM_E_QUEUE_OVERFLOW = 0x80041061

1223 WBEM_E_PRIVILEGE_NOT_HELD = 0x80041062

1224 WBEM_E_INVALID_OPERATOR = 0x80041063

1225 WBEM_E_CANNOT_BE_ABSTRACT = 0x80041065

1226 WBEM_E_AMENDED_OBJECT = 0x80041066

1227 WBEM_E_VETO_PUT = 0x8004107A

1228 WBEM_E_PROVIDER_SUSPENDED = 0x80041081

1229 WBEM_E_ENCRYPTED_CONNECTION_REQUIRED = 0x80041087

1230 WBEM_E_PROVIDER_TIMED_OUT = 0x80041088

1231 WBEM_E_NO_KEY = 0x80041089

1232 WBEM_E_PROVIDER_DISABLED = 0x8004108a

1233 WBEM_E_REGISTRATION_TOO_BROAD = 0x80042001

1234 WBEM_E_REGISTRATION_TOO_PRECISE = 0x80042002

1235

1236# 2.2.12 WBEM_CONNECT_OPTIONS Enumeration

1237 class WBEM_CONNECT_OPTIONS(NDRENUM):

1238 # [v1_enum] type

1239 structure = (

1240 ('Data', '<L'),

1241 )

1242 class enumItems(Enum):

1243 WBEM_FLAG_CONNECT_REPOSITORY_ONLY = 0x40

1244 WBEM_FLAG_CONNECT_PROVIDERS = 0x100

1245

1246# 2.2.14 ObjectArray Structure

1247 class ObjectArray(Structure):

1248 structure = (

1249 ('dwByteOrdering', '<L=0'),

1250 ('abSignature', '8s="WBEMDATA"'),

1251 ('dwSizeOfHeader1', '<L=0x1a'),

1252 ('dwDataSize1', '<L=0'),

1253 ('dwFlags', '<L=0'),

1254 ('bVersion', 'B=1'),

1255 ('bPacketType', 'B=0'),

1256 ('dwSizeOfHeader2', '<L=8'),

1257 ('dwDataSize2', '<L', 'len(self["wbemObjects"])+12'),

1258 ('dwSizeOfHeader3', '<L=12'),

1259 ('dwDataSize3', '<L', 'len(self["dwDataSize2"])-12)'),

1260 ('dwNumObjects', '<L=0'),

1261 ('_wbemObjects', '_-wbemObjects', 'self["dwDataSize3"]'),

1262 ('wbemObjects', ':'),

1263 )

1264

1265# 2.2.14.1 WBEM_DATAPACKET_OBJECT Structure

1266 class WBEM_DATAPACKET_OBJECT(Structure):

1267 structure = (

1268 ('dwSizeOfHeader', '<L=9'),

1269 ('dwSizeOfData', '<L','len(self["Object"])'),

1270 ('bObjectType', 'B=0'),

1271 ('_Object', '_-Object', 'self["dwSizeOfData"]'),

1272 ('Object', ':'),

1273 )

1274

1275# 2.2.14.2 WBEMOBJECT_CLASS Structure

1276 class WBEMOBJECT_CLASS(Structure):

1277 structure = (

1278 ('dwSizeOfHeader', '<L=8'),

1279 ('dwSizeOfData', '<L','len(self["ObjectData"])'),

1280 ('_ObjectData', '_-ObjectData', 'self["dwSizeOfData"]'),

1281 ('ObjectData', ':'),

1282 )

1283

1284# 2.2.14.3 WBEMOBJECT_INSTANCE Structure

1285 class WBEMOBJECT_INSTANCE(Structure):

1286 structure = (

1287 ('dwSizeOfHeader', '<L=0x18'),

1288 ('dwSizeOfData', '<L','len(self["ObjectData"])'),

1289 ('classID', '16s=b"\x00"*16'),

1290 ('_ObjectData', '_-ObjectData', 'self["dwSizeOfData"]'),

1291 ('ObjectData', ':'),

1292 )

1293

1294# 2.2.14.4 WBEMOBJECT_INSTANCE_NOCLASS Structure

1295 class WBEMOBJECT_INSTANCE_NOCLASS(Structure):

1296 structure = (

1297 ('dwSizeOfHeader', '<L=0x18'),

1298 ('dwSizeOfData', '<L','len(self["ObjectData"])'),

1299 ('classID', '16s=b"\x00"*16'),

1300 ('_ObjectData', '_-ObjectData', 'self["dwSizeOfData"]'),

1301 ('ObjectData', ':'),

1302 )

1303

1304# 2.2.15 WBEM_REFRESHED_OBJECT Structure

1305 class WBEM_REFRESHED_OBJECT(NDRSTRUCT):

1306 structure = (

1307 ('m_lRequestId', LONG),

1308 ('m_lBlobType', LONG),

1309 ('m_lBlobLength', LONG),

1310 ('m_pBlob', BYTE_ARRAY),

1311 )

1312

1313 class WBEM_REFRESHED_OBJECT_ARRAY(NDRUniConformantArray):

1314 item = WBEM_REFRESHED_OBJECT

1315

1316 class PWBEM_REFRESHED_OBJECT_ARRAY(NDRPOINTER):

1317 referent = (

1318 ('Data', WBEM_REFRESHED_OBJECT_ARRAY),

1319 )

1320

1321# 2.2.16 WBEM_INSTANCE_BLOB Enumeration

1322 class WBEM_INSTANCE_BLOB(Structure):

1323 structure = (

1324 ('Version', '<L=0x1'),

1325 ('numObjects', '<L=0'),

1326 ('Objects', ':'),

1327 )

1328

1329# 2.2.17 WBEM_INSTANCE_BLOB_TYPE Enumeration

1330 class WBEM_INSTANCE_BLOB_TYPE(NDRENUM):

1331 # [v1_enum] type

1332 structure = (

1333 ('Data', '<L'),

1334 )

1335 class enumItems(Enum):

1336 WBEM_FLAG_CONNECT_REPOSITORY_ONLY = 0x40

1337 WBEM_FLAG_CONNECT_PROVIDERS = 0x100

1338

1339# 2.2.26 _WBEM_REFRESH_INFO_NON_HIPERF Structure

1340 class _WBEM_REFRESH_INFO_NON_HIPERF(NDRSTRUCT):

1341 structure = (

1342 ('m_wszNamespace', LPWSTR),

1343 ('m_pTemplate', PMInterfacePointer),

1344 )

1345

1346# 2.2.27 _WBEM_REFRESH_INFO_REMOTE Structure

1347 class _WBEM_REFRESH_INFO_REMOTE(NDRSTRUCT):

1348 structure = (

1349 ('m_pRefresher', PMInterfacePointer),

1350 ('m_pTemplate', PMInterfacePointer),

1351 ('m_Guid', GUID),

1352 )

1353

1354# 2.2.25 WBEM_REFRESH_TYPE Enumeration

1355 class WBEM_REFRESH_TYPE(NDRENUM):

1356 class enumItems(Enum):

1357 WBEM_REFRESH_TYPE_INVALID = 0

1358 WBEM_REFRESH_TYPE_REMOTE = 3

1359 WBEM_REFRESH_TYPE_NON_HIPERF = 6

1360

1361# 2.2.28 _WBEM_REFRESH_INFO_UNION Union

1362 class _WBEM_REFRESH_INFO_UNION(NDRUNION):

1363 commonHdr = (

1364 ('tag', LONG),

1365 )

1366 union = {

1367 WBEM_REFRESH_TYPE.WBEM_REFRESH_TYPE_REMOTE : ('m_Remote', _WBEM_REFRESH_INFO_REMOTE),

1368 WBEM_REFRESH_TYPE.WBEM_REFRESH_TYPE_NON_HIPERF: ('m_NonHiPerf', _WBEM_REFRESH_INFO_NON_HIPERF),

1369 WBEM_REFRESH_TYPE.WBEM_REFRESH_TYPE_INVALID : ('m_hres', HRESULT),

1370 }

1371

1372# 2.2.20 _WBEM_REFRESH_INFO Structure

1373 class _WBEM_REFRESH_INFO(NDRSTRUCT):

1374 structure = (

1375 ('m_lType', LONG),

1376 ('m_Info', _WBEM_REFRESH_INFO_UNION),

1377 ('m_lCancelId', LONG),

1378 )

1379

1380# 2.2.21 _WBEM_REFRESHER_ID Structure

1381 class _WBEM_REFRESHER_ID(NDRSTRUCT):

1382 structure = (

1383 ('m_szMachineName', LPCSTR),

1384 ('m_dwProcessId', DWORD),

1385 ('m_guidRefresherId', GUID),

1386 )

1387

1388# 2.2.22 _WBEM_RECONNECT_INFO Structure

1389 class _WBEM_RECONNECT_INFO(NDRSTRUCT):

1390 structure = (

1391 ('m_lType', LPCSTR),

1392 ('m_pwcsPath', LPWSTR),

1393 )

1394

1395 class _WBEM_RECONNECT_INFO_ARRAY(NDRUniConformantArray):

1396 item = _WBEM_RECONNECT_INFO

1397

1398# 2.2.23 _WBEM_RECONNECT_RESULTS Structure

1399 class _WBEM_RECONNECT_RESULTS(NDRSTRUCT):

1400 structure = (

1401 ('m_lId', LONG),

1402 ('m_hr', HRESULT),

1403 )

1404

1405 class _WBEM_RECONNECT_RESULTS_ARRAY(NDRUniConformantArray):

1406 item = _WBEM_RECONNECT_INFO

1407

1408

1409################################################################################

1410# RPC CALLS

1411################################################################################

1412# 3.1.4.1 IWbemLevel1Login Interface

1413# 3.1.4.1.1 IWbemLevel1Login::EstablishPosition (Opnum 3)

1414 class IWbemLevel1Login_EstablishPosition(DCOMCALL):

1415 opnum = 3

1416 structure = (

1417 ('reserved1', LPWSTR),

1418 ('reserved2', DWORD),

1419 )

1420

1421 class IWbemLevel1Login_EstablishPositionResponse(DCOMANSWER):

1422 structure = (

1423 ('LocaleVersion', DWORD),

1424 ('ErrorCode', error_status_t),

1425 )

1426

1427# 3.1.4.1.2 IWbemLevel1Login::RequestChallenge (Opnum 4)

1428 class IWbemLevel1Login_RequestChallenge(DCOMCALL):

1429 opnum = 4

1430 structure = (

1431 ('reserved1', LPWSTR),

1432 ('reserved2', LPWSTR),

1433 )

1434

1435 class IWbemLevel1Login_RequestChallengeResponse(DCOMANSWER):

1436 structure = (

1437 ('reserved3', UCHAR_ARRAY_CV),

1438 ('ErrorCode', error_status_t),

1439 )

1440

1441# 3.1.4.1.3 IWbemLevel1Login::WBEMLogin (Opnum 5)

1442 class IWbemLevel1Login_WBEMLogin(DCOMCALL):

1443 opnum = 5

1444 structure = (

1445 ('reserved1', LPWSTR),

1446 ('reserved2', PUCHAR_ARRAY_CV),

1447 ('reserved3', LONG),

1448 ('reserved4', PMInterfacePointer),

1449 )

1450

1451 class IWbemLevel1Login_WBEMLoginResponse(DCOMANSWER):

1452 structure = (

1453 ('reserved5', UCHAR_ARRAY_CV),

1454 ('ErrorCode', error_status_t),

1455 )

1456

1457# 3.1.4.1.4 IWbemLevel1Login::NTLMLogin (Opnum 6)

1458 class IWbemLevel1Login_NTLMLogin(DCOMCALL):

1459 opnum = 6

1460 structure = (

1461 ('wszNetworkResource', LPWSTR),

1462 ('wszPreferredLocale', LPWSTR),

1463 ('lFlags', LONG),

1464 ('pCtx', PMInterfacePointer),

1465 )

1466

1467 class IWbemLevel1Login_NTLMLoginResponse(DCOMANSWER):

1468 structure = (

1469 ('ppNamespace', PMInterfacePointer),

1470 ('ErrorCode', error_status_t),

1471 )

1472

1473# 3.1.4.2 IWbemObjectSink Interface Server Details

1474# 3.1.4.2.1 IWbemObjectSink::Indicate (Opnum 3) Server details

1475 class IWbemObjectSink_Indicate(DCOMCALL):

1476 opnum = 3

1477 structure = (

1478 ('lObjectCount', LONG),

1479 ('apObjArray', PMInterfacePointer_ARRAY),

1480 )

1481

1482 class IWbemObjectSink_IndicateResponse(DCOMANSWER):

1483 structure = (

1484 ('ErrorCode', error_status_t),

1485 )

1486

1487# 3.1.4.2.2 IWbemObjectSink::SetStatus (Opnum 4) Server Details

1488 class IWbemObjectSink_SetStatus(DCOMCALL):

1489 opnum = 4

1490 structure = (

1491 ('lFlags', LONG),

1492 ('hResult', HRESULT),

1493 ('strParam', BSTR),

1494 ('pObjParam', PMInterfacePointer),

1495 )

1496

1497 class IWbemObjectSink_SetStatusResponse(DCOMANSWER):

1498 structure = (

1499 ('ErrorCode', error_status_t),

1500 )

1501

1502# 3.1.4.3 IWbemServices Interface

1503# 3.1.4.3.1 IWbemServices::OpenNamespace (Opnum 3)

1504 class IWbemServices_OpenNamespace(DCOMCALL):

1505 opnum = 3

1506 structure = (

1507 ('strNamespace', BSTR),

1508 ('lFlags', LONG),

1509 ('pCtx', PMInterfacePointer),

1510 ('ppWorkingNamespace', PMInterfacePointer),

1511 ('ppResult', PMInterfacePointer),

1512 )

1513

1514 class IWbemServices_OpenNamespaceResponse(DCOMANSWER):

1515 structure = (

1516 ('ppWorkingNamespace', PPMInterfacePointer),

1517 ('ppResult', PPMInterfacePointer),

1518 ('ErrorCode', error_status_t),

1519 )

1520

1521# 3.1.4.3.2 IWbemServices::CancelAsyncCall (Opnum 4)

1522 class IWbemServices_CancelAsyncCall(DCOMCALL):

1523 opnum = 4

1524 structure = (

1525 ('IWbemObjectSink', PMInterfacePointer),

1526 )

1527

1528 class IWbemServices_CancelAsyncCallResponse(DCOMANSWER):

1529 structure = (

1530 ('ErrorCode', error_status_t),

1531 )

1532

1533# 3.1.4.3.3 IWbemServices::QueryObjectSink (Opnum 5)

1534 class IWbemServices_QueryObjectSink(DCOMCALL):

1535 opnum = 5

1536 structure = (

1537 ('lFlags', LONG),

1538 )

1539

1540 class IWbemServices_QueryObjectSinkResponse(DCOMANSWER):

1541 structure = (

1542 ('ppResponseHandler', PMInterfacePointer),

1543 ('ErrorCode', error_status_t),

1544 )

1545

1546# 3.1.4.3.4 IWbemServices::GetObject (Opnum 6)

1547 class IWbemServices_GetObject(DCOMCALL):

1548 opnum = 6

1549 structure = (

1550 ('strObjectPath', BSTR),

1551 ('lFlags', LONG),

1552 ('pCtx', PMInterfacePointer),

1553 ('ppObject', PMInterfacePointer),

1554 ('ppCallResult', PMInterfacePointer),

1555 )

1556

1557 class IWbemServices_GetObjectResponse(DCOMANSWER):

1558 structure = (

1559 ('ppObject', PPMInterfacePointer),

1560 ('ppCallResult', PPMInterfacePointer),

1561 ('ErrorCode', error_status_t),

1562 )

1563

1564# 3.1.4.3.5 IWbemServices::GetObjectAsync (Opnum 7)

1565 class IWbemServices_GetObjectAsync(DCOMCALL):

1566 opnum = 7

1567 structure = (

1568 ('strObjectPath', BSTR),

1569 ('lFlags', LONG),

1570 ('pCtx', PMInterfacePointer),

1571 ('pResponseHandler', PMInterfacePointer),

1572 )

1573

1574 class IWbemServices_GetObjectAsyncResponse(DCOMANSWER):

1575 structure = (

1576 ('ErrorCode', error_status_t),

1577 )

1578

1579# 3.1.4.3.6 IWbemServices::PutClass (Opnum 8)

1580 class IWbemServices_PutClass(DCOMCALL):

1581 opnum = 8

1582 structure = (

1583 ('pObject', PMInterfacePointer),

1584 ('lFlags', LONG),

1585 ('pCtx', PMInterfacePointer),

1586 ('pResponseHandler', PMInterfacePointer),

1587 ('ppCallResult', PMInterfacePointer),

1588 )

1589

1590 class IWbemServices_PutClassResponse(DCOMANSWER):

1591 structure = (

1592 ('ppCallResult', PPMInterfacePointer),

1593 ('ErrorCode', error_status_t),

1594 )

1595

1596# 3.1.4.3.7 IWbemServices::PutClassAsync (Opnum 9)

1597 class IWbemServices_PutClassAsync(DCOMCALL):

1598 opnum = 9

1599 structure = (

1600 ('pObject', PMInterfacePointer),

1601 ('lFlags', LONG),

1602 ('pCtx', PMInterfacePointer),

1603 ('pResponseHandler', PMInterfacePointer),

1604 )

1605

1606 class IWbemServices_PutClassAsyncResponse(DCOMANSWER):

1607 structure = (

1608 ('ErrorCode', error_status_t),

1609 )

1610

1611# 3.1.4.3.8 IWbemServices::DeleteClass (Opnum 10)

1612 class IWbemServices_DeleteClass(DCOMCALL):

1613 opnum = 10

1614 structure = (

1615 ('strClass', BSTR),

1616 ('lFlags', LONG),

1617 ('pCtx', PMInterfacePointer),

1618 ('ppCallResult', PMInterfacePointer),

1619 )

1620

1621 class IWbemServices_DeleteClassResponse(DCOMANSWER):

1622 structure = (

1623 ('ppCallResult', PPMInterfacePointer),

1624 ('ErrorCode', error_status_t),

1625 )

1626

1627# 3.1.4.3.9 IWbemServices::DeleteClassAsync (Opnum 11)

1628 class IWbemServices_DeleteClassAsync(DCOMCALL):

1629 opnum = 11

1630 structure = (

1631 ('strClass', BSTR),

1632 ('lFlags', LONG),

1633 ('pCtx', PMInterfacePointer),

1634 ('pResponseHandler', PMInterfacePointer),

1635 )

1636

1637 class IWbemServices_DeleteClassAsyncResponse(DCOMANSWER):

1638 structure = (

1639 ('ErrorCode', error_status_t),

1640 )

1641

1642# 3.1.4.3.10 IWbemServices::CreateClassEnum (Opnum 12)

1643 class IWbemServices_CreateClassEnum(DCOMCALL):

1644 opnum = 12

1645 structure = (

1646 ('strSuperClass', BSTR),

1647 ('lFlags', LONG),

1648 ('pCtx', PMInterfacePointer),

1649 )

1650

1651 class IWbemServices_CreateClassEnumResponse(DCOMANSWER):

1652 structure = (

1653 ('ppEnum', PMInterfacePointer),

1654 ('ErrorCode', error_status_t),

1655 )

1656

1657# 3.1.4.3.11 IWbemServices::CreateClassEnumAsync (Opnum 13)

1658 class IWbemServices_CreateClassEnumAsync(DCOMCALL):

1659 opnum = 13

1660 structure = (

1661 ('strSuperClass', BSTR),

1662 ('lFlags', LONG),

1663 ('pCtx', PMInterfacePointer),

1664 ('pResponseHandler', PMInterfacePointer),

1665 )

1666

1667 class IWbemServices_CreateClassEnumAsyncResponse(DCOMANSWER):

1668 structure = (

1669 ('ErrorCode', error_status_t),

1670 )

1671

1672# 3.1.4.3.12 IWbemServices::PutInstance (Opnum 14)

1673 class IWbemServices_PutInstance(DCOMCALL):

1674 opnum = 14

1675 structure = (

1676 ('pInst', PMInterfacePointer),

1677 ('lFlags', LONG),

1678 ('pCtx', PMInterfacePointer),

1679 ('ppCallResult', PMInterfacePointer),

1680 )

1681

1682 class IWbemServices_PutInstanceResponse(DCOMANSWER):

1683 structure = (

1684 ('ppCallResult', PPMInterfacePointer),

1685 ('ErrorCode', error_status_t),

1686 )

1687

1688# 3.1.4.3.13 IWbemServices::PutInstanceAsync (Opnum 15)

1689 class IWbemServices_PutInstanceAsync(DCOMCALL):

1690 opnum = 15

1691 structure = (

1692 ('pInst', PMInterfacePointer),

1693 ('lFlags', LONG),

1694 ('pCtx', PMInterfacePointer),

1695 ('pResponseHandler', PMInterfacePointer),

1696 )

1697

1698 class IWbemServices_PutInstanceAsyncResponse(DCOMANSWER):

1699 structure = (

1700 ('ErrorCode', error_status_t),

1701 )

1702

1703# 3.1.4.3.14 IWbemServices::DeleteInstance (Opnum 16)

1704 class IWbemServices_DeleteInstance(DCOMCALL):

1705 opnum = 16

1706 structure = (

1707 ('strObjectPath', BSTR),

1708 ('lFlags', LONG),

1709 ('pCtx', PMInterfacePointer),

1710 ('ppCallResult', PMInterfacePointer),

1711 )

1712

1713 class IWbemServices_DeleteInstanceResponse(DCOMANSWER):

1714 structure = (

1715 ('ppCallResult', PPMInterfacePointer),

1716 ('ErrorCode', error_status_t),

1717 )

1718

1719# 3.1.4.3.15 IWbemServices::DeleteInstanceAsync (Opnum 17)

1720 class IWbemServices_DeleteInstanceAsync(DCOMCALL):

1721 opnum = 17

1722 structure = (

1723 ('strObjectPath', BSTR),

1724 ('lFlags', LONG),

1725 ('pCtx', PMInterfacePointer),

1726 ('pResponseHandler', PMInterfacePointer),

1727 )

1728

1729 class IWbemServices_DeleteInstanceAsyncResponse(DCOMANSWER):

1730 structure = (

1731 ('ErrorCode', error_status_t),

1732 )

1733

1734# 3.1.4.3.16 IWbemServices::CreateInstanceEnum (Opnum 18)

1735 class IWbemServices_CreateInstanceEnum(DCOMCALL):

1736 opnum = 18

1737 structure = (

1738 ('strSuperClass', BSTR),

1739 ('lFlags', LONG),

1740 ('pCtx', PMInterfacePointer),

1741 )

1742

1743 class IWbemServices_CreateInstanceEnumResponse(DCOMANSWER):

1744 structure = (

1745 ('ppEnum', PMInterfacePointer),

1746 ('ErrorCode', error_status_t),

1747 )

1748

1749# 3.1.4.3.17 IWbemServices::CreateInstanceEnumAsync (Opnum 19)

1750 class IWbemServices_CreateInstanceEnumAsync(DCOMCALL):

1751 opnum = 19

1752 structure = (

1753 ('strSuperClass', BSTR),

1754 ('lFlags', LONG),

1755 ('pCtx', PMInterfacePointer),

1756 ('pResponseHandler', PMInterfacePointer),

1757 )

1758

1759 class IWbemServices_CreateInstanceEnumAsyncResponse(DCOMANSWER):

1760 structure = (

1761 ('ErrorCode', error_status_t),

1762 )

1763

1764# 3.1.4.3.18 IWbemServices::ExecQuery (Opnum 20)

1765 class IWbemServices_ExecQuery(DCOMCALL):

1766 opnum = 20

1767 structure = (

1768 ('strQueryLanguage', BSTR),

1769 ('strQuery', BSTR),

1770 ('lFlags', LONG),

1771 ('pCtx', PMInterfacePointer),

1772 )

1773

1774 class IWbemServices_ExecQueryResponse(DCOMANSWER):

1775 structure = (

1776 ('ppEnum', PMInterfacePointer),

1777 ('ErrorCode', error_status_t),

1778 )

1779

1780# 3.1.4.3.19 IWbemServices::ExecQueryAsync (Opnum 21)

1781 class IWbemServices_ExecQueryAsync(DCOMCALL):

1782 opnum = 21

1783 structure = (

1784 ('strQueryLanguage', BSTR),

1785 ('strQuery', BSTR),

1786 ('lFlags', LONG),

1787 ('pCtx', PMInterfacePointer),

1788 ('pResponseHandler', PMInterfacePointer),

1789 )

1790

1791 class IWbemServices_ExecQueryAsyncResponse(DCOMANSWER):

1792 structure = (

1793 ('ErrorCode', error_status_t),

1794 )

1795

1796# 3.1.4.3.20 IWbemServices::ExecNotificationQuery (Opnum 22)

1797 class IWbemServices_ExecNotificationQuery(DCOMCALL):

1798 opnum = 22

1799 structure = (

1800 ('strQueryLanguage', BSTR),

1801 ('strQuery', BSTR),

1802 ('lFlags', LONG),

1803 ('pCtx', PMInterfacePointer),

1804 )

1805

1806 class IWbemServices_ExecNotificationQueryResponse(DCOMANSWER):

1807 structure = (

1808 ('ppEnum', PMInterfacePointer),

1809 ('ErrorCode', error_status_t),

1810 )

1811

1812# 3.1.4.3.21 IWbemServices::ExecNotificationQueryAsync (Opnum 23)

1813 class IWbemServices_ExecNotificationQueryAsync(DCOMCALL):

1814 opnum = 23

1815 structure = (

1816 ('strQueryLanguage', BSTR),

1817 ('strQuery', BSTR),

1818 ('lFlags', LONG),

1819 ('pCtx', PMInterfacePointer),

1820 ('pResponseHandler', PMInterfacePointer),

1821 )

1822

1823 class IWbemServices_ExecNotificationQueryAsyncResponse(DCOMANSWER):

1824 structure = (

1825 ('ErrorCode', error_status_t),

1826 )

1827

1828# 3.1.4.3.22 IWbemServices::ExecMethod (Opnum 24)

1829 class IWbemServices_ExecMethod(DCOMCALL):

1830 opnum = 24

1831 structure = (

1832 ('strObjectPath', BSTR),

1833 ('strMethodName', BSTR),

1834 ('lFlags', LONG),

1835 ('pCtx', PMInterfacePointer),

1836 ('pInParams', PMInterfacePointer),

1837 ('ppOutParams', PPMInterfacePointer),

1838 ('ppCallResult', PPMInterfacePointer),

1839 )

1840

1841 class IWbemServices_ExecMethodResponse(DCOMANSWER):

1842 structure = (

1843 ('ppOutParams', PPMInterfacePointer),

1844 ('ppCallResult', PPMInterfacePointer),

1845 ('ErrorCode', error_status_t),

1846 )

1847

1848# 3.1.4.3.23 IWbemServices::ExecMethodAsync (Opnum 25)

1849 class IWbemServices_ExecMethodAsync(DCOMCALL):

1850 opnum = 25

1851 structure = (

1852 ('strObjectPath', BSTR),

1853 ('strMethodName', BSTR),

1854 ('lFlags', LONG),

1855 ('pCtx', PMInterfacePointer),

1856 ('pInParams', PMInterfacePointer),

1857 ('pResponseHandler', PMInterfacePointer),

1858 )

1859

1860 class IWbemServices_ExecMethodAsyncResponse(DCOMANSWER):

1861 structure = (

1862 ('ErrorCode', error_status_t),

1863 )

1864

1865# 3.1.4.4 IEnumWbemClassObject Interface

1866# 3.1.4.4.1 IEnumWbemClassObject::Reset (Opnum 3)

1867 class IEnumWbemClassObject_Reset(DCOMCALL):

1868 opnum = 3

1869 structure = (

1870 )

1871

1872 class IEnumWbemClassObject_ResetResponse(DCOMANSWER):

1873 structure = (

1874 ('ErrorCode', error_status_t),

1875 )

1876

1877# 3.1.4.4.2 IEnumWbemClassObject::Next (Opnum 4)

1878 class IEnumWbemClassObject_Next(DCOMCALL):

1879 opnum = 4

1880 structure = (

1881 ('lTimeout', ULONG),

1882 ('uCount', ULONG),

1883 )

1884

1885 class IEnumWbemClassObject_NextResponse(DCOMANSWER):

1886 structure = (

1887 ('apObjects', PMInterfacePointer_ARRAY_CV),

1888 ('puReturned', ULONG),

1889 ('ErrorCode', error_status_t),

1890 )

1891

1892# 3.1.4.4.3 IEnumWbemClassObject::NextAsync (Opnum 5)

1893 class IEnumWbemClassObject_NextAsync(DCOMCALL):

1894 opnum = 5

1895 structure = (

1896 ('lTimeout', LONG),

1897 ('pSink', PMInterfacePointer),

1898 )

1899

1900 class IEnumWbemClassObject_NextAsyncResponse(DCOMANSWER):

1901 structure = (

1902 ('ErrorCode', error_status_t),

1903 )

1904

1905# 3.1.4.4.4 IEnumWbemClassObject::Clone (Opnum 6)

1906 class IEnumWbemClassObject_Clone(DCOMCALL):

1907 opnum = 6

1908 structure = (

1909 )

1910

1911 class IEnumWbemClassObject_CloneResponse(DCOMANSWER):

1912 structure = (

1913 ('ppEnum', PMInterfacePointer),

1914 ('ErrorCode', error_status_t),

1915 )

1916

1917# 3.1.4.4.5 IEnumWbemClassObject::Skip (Opnum 7)

1918 class IEnumWbemClassObject_Skip(DCOMCALL):

1919 opnum = 7

1920 structure = (

1921 ('lTimeout', LONG),

1922 ('uCount', ULONG),

1923 )

1924

1925 class IEnumWbemClassObject_SkipResponse(DCOMANSWER):

1926 structure = (

1927 ('ErrorCode', error_status_t),

1928 )

1929

1930# 3.1.4.5 IWbemCallResult Interface

1931# 3.1.4.5.1 IWbemCallResult::GetResultObject (Opnum 3)

1932 class IWbemCallResult_GetResultObject(DCOMCALL):

1933 opnum = 3

1934 structure = (

1935 ('lTimeout', LONG),

1936 )

1937

1938 class IWbemCallResult_GetResultObjectResponse(DCOMANSWER):

1939 structure = (

1940 ('ppResultObject', PMInterfacePointer),

1941 ('ErrorCode', error_status_t),

1942 )

1943

1944# 3.1.4.5.2 IWbemCallResult::GetResultString (Opnum 4)

1945 class IWbemCallResult_GetResultString(DCOMCALL):

1946 opnum = 4

1947 structure = (

1948 ('lTimeout', LONG),

1949 )

1950

1951 class IWbemCallResult_GetResultStringResponse(DCOMANSWER):

1952 structure = (

1953 ('pstrResultString', BSTR),

1954 ('ErrorCode', error_status_t),

1955 )

1956

1957# 3.1.4.5.3 IWbemCallResult::GetResultServices (Opnum 5)

1958 class IWbemCallResult_GetResultServices(DCOMCALL):

1959 opnum = 5

1960 structure = (

1961 ('lTimeout', LONG),

1962 )

1963

1964 class IWbemCallResult_GetResultServicesResponse(DCOMANSWER):

1965 structure = (

1966 ('ppServices', PMInterfacePointer),

1967 ('ErrorCode', error_status_t),

1968 )

1969

1970# 3.1.4.5.4 IWbemCallResult::GetCallStatus (Opnum 6)

1971 class IWbemCallResult_GetCallStatus(DCOMCALL):

1972 opnum = 6

1973 structure = (

1974 ('lTimeout', LONG),

1975 )

1976

1977 class IWbemCallResult_GetCallStatusResponse(DCOMANSWER):

1978 structure = (

1979 ('plStatus', LONG),

1980 ('ErrorCode', error_status_t),

1981 )

1982

1983# 3.1.4.6 IWbemFetchSmartEnum Interface

1984# 3.1.4.6.1 IWbemFetchSmartEnum::GetSmartEnum (Opnum 3)

1985 class IWbemFetchSmartEnum_GetSmartEnum(DCOMCALL):

1986 opnum = 3

1987 structure = (

1988 )

1989

1990 class IWbemFetchSmartEnum_GetSmartEnumResponse(DCOMANSWER):

1991 structure = (

1992 ('ppSmartEnum', PMInterfacePointer),

1993 ('ErrorCode', error_status_t),

1994 )

1995

1996# 3.1.4.7 IWbemWCOSmartEnum Interface

1997# 3.1.4.7.1 IWbemWCOSmartEnum::Next (Opnum 3)

1998 class IWbemWCOSmartEnum_Next(DCOMCALL):

1999 opnum = 3

2000 structure = (

2001 ('proxyGUID', REFGUID),

2002 ('lTimeout', LONG),

2003 ('uCount', ULONG),

2004 )

2005

2006 class IWbemWCOSmartEnum_NextResponse(DCOMANSWER):

2007 structure = (

2008 ('puReturned', ULONG),

2009 ('pdwBuffSize', ULONG),

2010 ('pBuffer', BYTE_ARRAY),

2011 ('ErrorCode', error_status_t),

2012 )

2013

2014# 3.1.4.8 IWbemLoginClientID Interface

2015# 3.1.4.8.1 IWbemLoginClientID::SetClientInfo (Opnum 3)

2016 class IWbemLoginClientID_SetClientInfo(DCOMCALL):

2017 opnum = 3

2018 structure = (

2019 ('wszClientMachine', LPWSTR),

2020 ('lClientProcId', LONG),

2021 ('lReserved', LONG),

2022 )

2023

2024 class IWbemLoginClientID_SetClientInfoResponse(DCOMANSWER):

2025 structure = (

2026 ('ErrorCode', error_status_t),

2027 )

2028

2029# 3.1.4.9 IWbemLoginHelper Interface

2030# 3.1.4.9.1 IWbemLoginHelper::SetEvent (Opnum 3)

2031 class IWbemLoginHelper_SetEvent(DCOMCALL):

2032 opnum = 3

2033 structure = (

2034 ('sEventToSet', LPCSTR),

2035 )

2036

2037 class IWbemLoginHelper_SetEventResponse(DCOMANSWER):

2038 structure = (

2039 ('ErrorCode', error_status_t),

2040 )

2041

2042#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

2043# 3.1.4.10 IWbemBackupRestore Interface

2044# 3.1.4.10.1 IWbemBackupRestore::Backup (Opnum 3)

2045 class IWbemBackupRestore_Backup(DCOMCALL):

2046 opnum = 3

2047 structure = (

2048 ('strBackupToFile', LPWSTR),

2049 ('lFlags', LONG),

2050 )

2051

2052 class IWbemBackupRestore_BackupResponse(DCOMANSWER):

2053 structure = (

2054 ('ErrorCode', error_status_t),

2055 )

2056

2057# 3.1.4.10.2 IWbemBackupRestore::Restore (Opnum 4)

2058 class IWbemBackupRestore_Restore(DCOMCALL):

2059 opnum = 4

2060 structure = (

2061 ('strRestoreFromFile', LPWSTR),

2062 ('lFlags', LONG),

2063 )

2064

2065 class IWbemBackupRestore_RestoreResponse(DCOMANSWER):

2066 structure = (

2067 ('ErrorCode', error_status_t),

2068 )

2069

2070# 3.1.4.11 IWbemBackupRestoreEx Interface

2071# 3.1.4.11.1 IWbemBackupRestoreEx::Pause (Opnum 5)

2072 class IWbemBackupRestoreEx_Pause(DCOMCALL):

2073 opnum = 5

2074 structure = (

2075 )

2076

2077 class IWbemBackupRestoreEx_PauseResponse(DCOMANSWER):

2078 structure = (

2079 ('ErrorCode', error_status_t),

2080 )

2081

2082# 3.1.4.11.2 IWbemBackupRestoreEx::Resume (Opnum 6)

2083 class IWbemBackupRestoreEx_Resume(DCOMCALL):

2084 opnum = 6

2085 structure = (

2086 )

2087

2088 class IWbemBackupRestoreEx_ResumeResponse(DCOMANSWER):

2089 structure = (

2090 ('ErrorCode', error_status_t),

2091 )

2092

2093# 3.1.4.12 IWbemRefreshingServices Interface

2094# 3.1.4.12.1 IWbemRefreshingServices::AddObjectToRefresher (Opnum 3)

2095 class IWbemRefreshingServices_AddObjectToRefresher(DCOMCALL):

2096 opnum = 3

2097 structure = (

2098 ('pRefresherId', _WBEM_REFRESHER_ID),

2099 ('wszPath', LPWSTR),

2100 ('lFlags', LONG),

2101 ('pContext', PMInterfacePointer),

2102 ('dwClientRefrVersion', DWORD),

2103 )

2104

2105 class IWbemRefreshingServices_AddObjectToRefresherResponse(DCOMANSWER):

2106 structure = (

2107 ('pInfo', _WBEM_REFRESH_INFO),

2108 ('pdwSvrRefrVersion', DWORD),

2109 ('ErrorCode', error_status_t),

2110 )

2111

2112# 3.1.4.12.2 IWbemRefreshingServices::AddObjectToRefresherByTemplate (Opnum 4)

2113 class IWbemRefreshingServices_AddObjectToRefresherByTemplate(DCOMCALL):

2114 opnum = 4

2115 structure = (

2116 ('pRefresherId', _WBEM_REFRESHER_ID),

2117 ('pTemplate', PMInterfacePointer),

2118 ('lFlags', LONG),

2119 ('pContext', PMInterfacePointer),

2120 ('dwClientRefrVersion', DWORD),

2121 )

2122

2123 class IWbemRefreshingServices_AddObjectToRefresherByTemplateResponse(DCOMANSWER):

2124 structure = (

2125 ('pInfo', _WBEM_REFRESH_INFO),

2126 ('pdwSvrRefrVersion', DWORD),

2127 ('ErrorCode', error_status_t),

2128 )

2129

2130# 3.1.4.12.3 IWbemRefreshingServices::AddEnumToRefresher (Opnum 5)

2131 class IWbemRefreshingServices_AddEnumToRefresher(DCOMCALL):

2132 opnum = 5

2133 structure = (

2134 ('pRefresherId', _WBEM_REFRESHER_ID),

2135 ('wszClass', LPWSTR),

2136 ('lFlags', LONG),

2137 ('pContext', PMInterfacePointer),

2138 ('dwClientRefrVersion', DWORD),

2139 )

2140

2141 class IWbemRefreshingServices_AddEnumToRefresherResponse(DCOMANSWER):

2142 structure = (

2143 ('pInfo', _WBEM_REFRESH_INFO),

2144 ('pdwSvrRefrVersion', DWORD),

2145 ('ErrorCode', error_status_t),

2146 )

2147

2148# 3.1.4.12.4 IWbemRefreshingServices::RemoveObjectFromRefresher (Opnum 6)

2149 class IWbemRefreshingServices_RemoveObjectFromRefresher(DCOMCALL):

2150 opnum = 6

2151 structure = (

2152 ('pRefresherId', _WBEM_REFRESHER_ID),

2153 ('lId', LONG),

2154 ('lFlags', LONG),

2155 ('dwClientRefrVersion', DWORD),

2156 )

2157

2158 class IWbemRefreshingServices_RemoveObjectFromRefresherResponse(DCOMANSWER):

2159 structure = (

2160 ('pdwSvrRefrVersion', DWORD),

2161 ('ErrorCode', error_status_t),

2162 )

2163

2164# 3.1.4.12.5 IWbemRefreshingServices::GetRemoteRefresher (Opnum 7)

2165 class IWbemRefreshingServices_GetRemoteRefresher(DCOMCALL):

2166 opnum = 7

2167 structure = (

2168 ('pRefresherId', _WBEM_REFRESHER_ID),

2169 ('lFlags', LONG),

2170 ('dwClientRefrVersion', DWORD),

2171 )

2172

2173 class IWbemRefreshingServices_GetRemoteRefresherResponse(DCOMANSWER):

2174 structure = (

2175 ('ppRemRefresher', PMInterfacePointer),

2176 ('pGuid', GUID),

2177 ('pdwSvrRefrVersion', DWORD),

2178 ('ErrorCode', error_status_t),

2179 )

2180

2181# 3.1.4.12.6 IWbemRefreshingServices::ReconnectRemoteRefresher (Opnum 8)

2182 class IWbemRefreshingServices_ReconnectRemoteRefresher(DCOMCALL):

2183 opnum = 8

2184 structure = (

2185 ('pRefresherId', _WBEM_REFRESHER_ID),

2186 ('lFlags', LONG),

2187 ('lNumObjects', LONG),

2188 ('dwClientRefrVersion', DWORD),

2189 ('apReconnectInfo', _WBEM_RECONNECT_INFO_ARRAY),

2190 )

2191

2192 class IWbemRefreshingServices_ReconnectRemoteRefresherResponse(DCOMANSWER):

2193 structure = (

2194 ('apReconnectResults', _WBEM_RECONNECT_RESULTS_ARRAY),

2195 ('pdwSvrRefrVersion', DWORD),

2196 ('ErrorCode', error_status_t),

2197 )

2198

2199# 3.1.4.13 IWbemRemoteRefresher Interface

2200# 3.1.4.13.1 IWbemRemoteRefresher::RemoteRefresh (Opnum 3)

2201 class IWbemRemoteRefresher_RemoteRefresh(DCOMCALL):

2202 opnum = 3

2203 structure = (

2204 ('lFlags', LONG),

2205 )

2206

2207 class IWbemRemoteRefresher_RemoteRefreshResponse(DCOMANSWER):

2208 structure = (

2209 ('plNumObjects', _WBEM_RECONNECT_RESULTS_ARRAY),

2210 ('paObjects', PWBEM_REFRESHED_OBJECT_ARRAY),

2211 ('ErrorCode', error_status_t),

2212 )

2213

2214# 3.1.4.13.2 IWbemRemoteRefresher::StopRefreshing (Opnum 4)

2215 class IWbemRemoteRefresher_StopRefreshing(DCOMCALL):

2216 opnum = 4

2217 structure = (

2218 ('lNumIds', LONG),

2219 ('aplIds', PULONG_ARRAY),

2220 ('lFlags', LONG),

2221 )

2222

2223 class IWbemRemoteRefresher_StopRefreshingResponse(DCOMANSWER):

2224 structure = (

2225 ('ErrorCode', error_status_t),

2226 )

2227

2228# 3.1.4.14 IWbemShutdown Interface

2229# 3.1.4.14.1 IWbemShutdown::Shutdown (Opnum 3)

2230 class IWbemShutdown_Shutdown(DCOMCALL):

2231 opnum = 3

2232 structure = (

2233 ('reserved1', LONG),

2234 ('reserved2', ULONG),

2235 ('reserved3', PMInterfacePointer),

2236 )

2237

2238 class IWbemShutdown_ShutdownResponse(DCOMANSWER):

2239 structure = (

2240 ('ErrorCode', error_status_t),

2241 )

2242

2243# 3.1.4.15 IUnsecuredApartment Interface

2244# 3.1.4.15.1 IUnsecuredApartment::CreateObjectStub (Opnum 3)

2245 class IUnsecuredApartment_CreateObjectStub(DCOMCALL):

2246 opnum = 3

2247 structure = (

2248 ('reserved1', PMInterfacePointer),

2249 )

2250

2251 class IUnsecuredApartment_CreateObjectStubResponse(DCOMANSWER):

2252 structure = (

2253 ('reserved2', PMInterfacePointer),

2254 ('ErrorCode', error_status_t),

2255 )

2256

2257# 3.1.4.16 IWbemUnsecuredApartment Interface

2258# 3.1.4.16.1 IWbemUnsecuredApartment::CreateSinkStub (Opnum 3)

2259 class IWbemUnsecuredApartment_CreateSinkStub(DCOMCALL):

2260 opnum = 3

2261 structure = (

2262 ('reserved1', PMInterfacePointer),

2263 ('reserved2', DWORD),

2264 ('reserved3', LPWSTR),

2265 )

2266

2267 class IWbemUnsecuredApartment_CreateSinkStubResponse(DCOMANSWER):

2268 structure = (

2269 ('reserved4', PMInterfacePointer),

2270 ('ErrorCode', error_status_t),

2271 )

2272

2273################################################################################

2274# OPNUMs and their corresponding structures

2275################################################################################

2276 OPNUMS = {

2277}

2278

2279################################################################################

2280# HELPER FUNCTIONS AND INTERFACES

2281################################################################################

2282 def checkNullString(string):

2283 if string == NULL:

2284 return string

2285

2286 if string[-1:] != '\x00': 2286 ↛ 2289line 2286 didn't jump to line 2289, because the condition on line 2286 was never false

2287 return string + '\x00'

2288 else:

2289 return string

2290

2291 class IWbemClassObject(IRemUnknown):

2292 def __init__(self, interface, iWbemServices = None):

2293 IRemUnknown.__init__(self,interface)

2294 self._iid = IID_IWbemClassObject

2295 self.__iWbemServices = iWbemServices

2296 self.__methods = None

2297

2298 objRef = self.get_objRef()

2299 objRef = OBJREF_CUSTOM(objRef)

2300 self.encodingUnit = ENCODING_UNIT(objRef['pObjectData'])

2301 self.parseObject()

2302 if self.encodingUnit['ObjectBlock'].isInstance() is False:

2303 self.createMethods(self.getClassName(), self.getMethods())

2304 else:

2305 self.createProperties(self.getProperties())

2306

2307 def __getattr__(self, attr):

2308 if attr.startswith('__') is not True: 2308 ↛ 2336line 2308 didn't jump to line 2336, because the condition on line 2308 was never false

2309 properties = self.getProperties()

2310 # Let's see if there's a key property so we can ExecMethod

2311 keyProperty = None

2312 for pName in properties:

2313 if 'key' in properties[pName]['qualifiers']:

2314 keyProperty = pName

2315

2316 if keyProperty is None: 2316 ↛ 2317line 2316 didn't jump to line 2317, because the condition on line 2316 was never true

2317 LOG.error("I don't have a key property in this set!")

2318 else:

2319 if self.__methods is None: 2319 ↛ 2323line 2319 didn't jump to line 2323, because the condition on line 2319 was never false

2320 classObject,_ = self.__iWbemServices.GetObject(self.getClassName())

2321 self.__methods = classObject.getMethods()

2322

2323 if attr in self.__methods: 2323 ↛ 2336line 2323 didn't jump to line 2336, because the condition on line 2323 was never false

2324 # Now we gotta build the class name to be called through ExecMethod

2325 if self.getProperties()[keyProperty]['stype'] != 'string': 2325 ↛ 2326line 2325 didn't jump to line 2326, because the condition on line 2325 was never true

2326 instanceName = '%s.%s=%s' % (

2327 self.getClassName(), keyProperty, self.getProperties()[keyProperty]['value'])

2328 else:

2329 instanceName = '%s.%s="%s"' % (

2330 self.getClassName(), keyProperty, self.getProperties()[keyProperty]['value'])

2331

2332 self.createMethods(instanceName , self.__methods)

2333 #print dir(self)

2334 return getattr(self, attr)

2335

2336 raise AttributeError("%r object has no attribute %r" %

2337 (self.__class__, attr))

2338

2339 def parseObject(self):

2340 self.encodingUnit['ObjectBlock'].parseObject()

2341

2342 def getObject(self):

2343 return self.encodingUnit['ObjectBlock']

2344

2345 def getClassName(self):

2346 if self.encodingUnit['ObjectBlock'].isInstance() is False:

2347 return self.encodingUnit['ObjectBlock']['ClassType']['CurrentClass'].getClassName().split(' ')[0]

2348 else:

2349 return self.encodingUnit['ObjectBlock']['InstanceType']['CurrentClass'].getClassName().split(' ')[0]

2350

2351 def printInformation(self):

2352 return self.encodingUnit['ObjectBlock'].printInformation()

2353

2354 def getProperties(self):

2355 if self.encodingUnit['ObjectBlock'].ctCurrent is None: 2355 ↛ 2356line 2355 didn't jump to line 2356, because the condition on line 2355 was never true

2356 return ()

2357 return self.encodingUnit['ObjectBlock'].ctCurrent['properties']

2358

2359 def getMethods(self):

2360 if self.encodingUnit['ObjectBlock'].ctCurrent is None: 2360 ↛ 2361line 2360 didn't jump to line 2361, because the condition on line 2360 was never true

2361 return ()

2362 return self.encodingUnit['ObjectBlock'].ctCurrent['methods']

2363

2364 def marshalMe(self):

2365 # So, in theory, we have the OBJCUSTOM built, but

2366 # we need to update the values

2367 # That's what we'll do

2368

2369 instanceHeap = b''

2370 valueTable = b''

2371 ndTable = 0

2372 parametersClass = ENCODED_STRING()

2373 parametersClass['Character'] = self.getClassName()

2374 instanceHeap += parametersClass.getData()

2375 curHeapPtr = len(instanceHeap)

2376 properties = self.getProperties()

2377 for i, propName in enumerate(properties):

2378 propRecord = properties[propName]

2379 itemValue = getattr(self, propName)

2380 print("PropName %r, Value: %r" % (propName,itemValue))

2381

2382 pType = propRecord['type'] & (~(CIM_ARRAY_FLAG|Inherited))

2383 if propRecord['type'] & CIM_ARRAY_FLAG:

2384 # Not yet ready

2385 packStr = HEAPREF[:-2]

2386 else:

2387 packStr = CIM_TYPES_REF[pType][:-2]

2388

2389 if propRecord['type'] & CIM_ARRAY_FLAG:

2390 if itemValue is None:

2391 ndTable |= 2 << (2*i)

2392 valueTable += pack(packStr, 0)

2393 else:

2394 valueTable += pack('<L', curHeapPtr)

2395 arraySize = pack(HEAPREF[:-2], len(itemValue))

2396 packStrArray = CIM_TYPES_REF[pType][:-2]

2397 arrayItems = b''

2398 for j in range(len(itemValue)):

2399 arrayItems += pack(packStrArray, itemValue[j])

2400 instanceHeap += arraySize + arrayItems

2401 curHeapPtr = len(instanceHeap)

2402 elif pType in (CIM_TYPE_ENUM.CIM_TYPE_UINT8.value, CIM_TYPE_ENUM.CIM_TYPE_UINT16.value,

2403 CIM_TYPE_ENUM.CIM_TYPE_UINT32.value, CIM_TYPE_ENUM.CIM_TYPE_UINT64.value):

2404 if itemValue is None:

2405 ndTable |= 2 << (2 * i)

2406 valueTable += pack(packStr, 0)

2407 else:

2408 valueTable += pack(packStr, int(itemValue))

2409 elif pType in (CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value,):

2410 if itemValue is None:

2411 ndTable |= 2 << (2 * i)

2412 valueTable += pack(packStr, False)

2413 else:

2414 valueTable += pack(packStr, bool(itemValue))

2415 elif pType not in (CIM_TYPE_ENUM.CIM_TYPE_STRING.value, CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value,

2416 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value, CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value):

2417 if itemValue is None:

2418 ndTable |= 2 << (2 * i)

2419 valueTable += pack(packStr, -1)

2420 else:

2421 valueTable += pack(packStr, itemValue)

2422 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2423 # For now we just pack None

2424 valueTable += b'\x00'*4

2425 # The default property value is NULL, and it is

2426 # inherited from a parent class.

2427 if itemValue is None:

2428 ndTable |= 3 << (2*i)

2429 else:

2430 if itemValue == '':

2431 ndTable |= 2 << (2*i)

2432 valueTable += pack('<L', 0)

2433 else:

2434 strIn = ENCODED_STRING()

2435 strIn['Character'] = itemValue

2436 valueTable += pack('<L', curHeapPtr)

2437 instanceHeap += strIn.getData()

2438 curHeapPtr = len(instanceHeap)

2439

2440 ndTableLen = (len(properties) - 1) // 4 + 1

2441 packedNdTable = b''

2442 for i in range(ndTableLen):

2443 packedNdTable += pack('B', ndTable & 0xff)

2444 ndTable >>= 8

2445

2446 # Now let's update the structure

2447 objRef = self.get_objRef()

2448 objRef = OBJREF_CUSTOM(objRef)

2449 encodingUnit = ENCODING_UNIT(objRef['pObjectData'])

2450

2451 currentClass = encodingUnit['ObjectBlock']['InstanceType']['CurrentClass']

2452 encodingUnit['ObjectBlock']['InstanceType']['CurrentClass'] = b''

2453

2454 encodingUnit['ObjectBlock']['InstanceType']['NdTable_ValueTable'] = packedNdTable + valueTable

2455 encodingUnit['ObjectBlock']['InstanceType']['InstanceHeap']['HeapLength'] = len(instanceHeap) | 0x80000000

2456 encodingUnit['ObjectBlock']['InstanceType']['InstanceHeap']['HeapItem'] = instanceHeap

2457

2458 encodingUnit['ObjectBlock']['InstanceType']['EncodingLength'] = len(encodingUnit['ObjectBlock']['InstanceType'])

2459 encodingUnit['ObjectBlock']['InstanceType']['CurrentClass'] = currentClass

2460

2461 encodingUnit['ObjectEncodingLength'] = len(encodingUnit['ObjectBlock'])

2462

2463 #encodingUnit.dump()

2464 #ENCODING_UNIT(str(encodingUnit)).dump()

2465

2466 objRef['pObjectData'] = encodingUnit

2467

2468 return objRef

2469

2470 def SpawnInstance(self):

2471 # Doing something similar to:

2472 # https://docs.microsoft.com/windows/desktop/api/wbemcli/nf-wbemcli-iwbemclassobject-spawninstance

2473 #

2474 if self.encodingUnit['ObjectBlock'].isInstance() is False:

2475 # We need to convert some things to transform a class into an instance

2476 encodingUnit = ENCODING_UNIT()

2477

2478 instanceData = OBJECT_BLOCK()

2479 instanceData.structure += OBJECT_BLOCK.decoration

2480 instanceData.structure += OBJECT_BLOCK.instanceType

2481 instanceData['ObjectFlags'] = 6

2482 instanceData['Decoration'] = self.encodingUnit['ObjectBlock']['Decoration'].getData()

2483

2484 instanceType = INSTANCE_TYPE()

2485 instanceType['CurrentClass'] = b''

2486

2487 # Let's create the heap for the parameters

2488 instanceHeap = b''

2489 valueTable = b''

2490 parametersClass = ENCODED_STRING()

2491 parametersClass['Character'] = self.getClassName()

2492 instanceHeap += parametersClass.getData()

2493 curHeapPtr = len(instanceHeap)

2494

2495 ndTable = 0

2496 properties = self.getProperties()

2497

2498 # Let's initialize the values

2499 for i, propName in enumerate(properties):

2500 propRecord = properties[propName]

2501

2502 pType = propRecord['type'] & (~(CIM_ARRAY_FLAG|Inherited))

2503 if propRecord['type'] & CIM_ARRAY_FLAG:

2504 # Not yet ready

2505 #print paramDefinition

2506 #raise

2507 packStr = HEAPREF[:-2]

2508 else:

2509 packStr = CIM_TYPES_REF[pType][:-2]

2510

2511 if propRecord['type'] & CIM_ARRAY_FLAG:

2512 valueTable += pack(packStr, 0)

2513 elif pType not in (CIM_TYPE_ENUM.CIM_TYPE_STRING.value, CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value,

2514 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value, CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value):

2515 valueTable += pack(packStr, 0)

2516 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2517 # For now we just pack None

2518 valueTable += b'\x00'*4

2519 # The default property value is NULL, and it is

2520 # inherited from a parent class.

2521 ndTable |= 3 << (2*i)

2522 else:

2523 strIn = ENCODED_STRING()

2524 strIn['Character'] = ''

2525 valueTable += pack('<L', curHeapPtr)

2526 instanceHeap += strIn.getData()

2527 curHeapPtr = len(instanceHeap)

2528

2529 ndTableLen = (len(properties) - 1) // 4 + 1

2530 packedNdTable = b''

2531 for i in range(ndTableLen):

2532 packedNdTable += pack('B', ndTable & 0xff)

2533 ndTable >>= 8

2534

2535 instanceType['NdTable_ValueTable'] = packedNdTable + valueTable

2536

2537 instanceType['InstanceQualifierSet'] = b'\x04\x00\x00\x00\x01'

2538

2539 instanceType['InstanceHeap'] = HEAP()

2540 instanceType['InstanceHeap']['HeapItem'] = instanceHeap

2541 instanceType['InstanceHeap']['HeapLength'] = len(instanceHeap) | 0x80000000

2542 instanceType['EncodingLength'] = len(instanceType)

2543

2544 instanceType['CurrentClass'] = self.encodingUnit['ObjectBlock']['ClassType']['CurrentClass']['ClassPart']

2545 instanceData['InstanceType'] = instanceType.getData()

2546

2547 encodingUnit['ObjectBlock'] = instanceData

2548 encodingUnit['ObjectEncodingLength'] = len(instanceData)

2549

2550 #ENCODING_UNIT(str(encodingUnit)).dump()

2551

2552 objRefCustomIn = OBJREF_CUSTOM()

2553 objRefCustomIn['iid'] = self._iid

2554 objRefCustomIn['clsid'] = CLSID_WbemClassObject

2555 objRefCustomIn['cbExtension'] = 0

2556 objRefCustomIn['ObjectReferenceSize'] = len(encodingUnit)

2557 objRefCustomIn['pObjectData'] = encodingUnit

2558

2559 # There's gotta be a better way to do this

2560 # I will reimplement this stuff once I know it works

2561 import copy

2562 newObj = copy.deepcopy(self)

2563 newObj.set_objRef(objRefCustomIn.getData())

2564 newObj.process_interface(objRefCustomIn.getData())

2565 newObj.encodingUnit = ENCODING_UNIT(encodingUnit.getData())

2566 newObj.parseObject()

2567 if newObj.encodingUnit['ObjectBlock'].isInstance() is False:

2568 newObj.createMethods(newObj.getClassName(), newObj.getMethods())

2569 else:

2570 newObj.createProperties(newObj.getProperties())

2571

2572 return newObj

2573 else:

2574 return self

2575

2576 def createProperties(self, properties):

2577 for property in properties:

2578 # Do we have an object property?

2579 if properties[property]['type'] == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value: 2579 ↛ 2581line 2579 didn't jump to line 2581, because the condition on line 2579 was never true

2580 # Yes.. let's create an Object for it too

2581 objRef = OBJREF_CUSTOM()

2582 objRef['iid'] = self._iid

2583 objRef['clsid'] = CLSID_WbemClassObject

2584 objRef['cbExtension'] = 0

2585 objRef['ObjectReferenceSize'] = len(properties[property]['value'].getData())

2586 objRef['pObjectData'] = properties[property]['value']

2587 value = IWbemClassObject( INTERFACE(self.get_cinstance(), objRef.getData(), self.get_ipidRemUnknown(),

2588 oxid=self.get_oxid(), target=self.get_target()))

2589 elif properties[property]['type'] == CIM_TYPE_ENUM.CIM_ARRAY_OBJECT.value: 2589 ↛ 2590line 2589 didn't jump to line 2590, because the condition on line 2589 was never true

2590 if isinstance(properties[property]['value'], list):

2591 value = list()

2592 for item in properties[property]['value']:

2593 # Yes.. let's create an Object for it too

2594 objRef = OBJREF_CUSTOM()

2595 objRef['iid'] = self._iid

2596 objRef['clsid'] = CLSID_WbemClassObject

2597 objRef['cbExtension'] = 0

2598 objRef['ObjectReferenceSize'] = len(item.getData())

2599 objRef['pObjectData'] = item

2600 wbemClass = IWbemClassObject(

2601 INTERFACE(self.get_cinstance(), objRef.getData(), self.get_ipidRemUnknown(),

2602 oxid=self.get_oxid(), target=self.get_target()))

2603 value.append(wbemClass)

2604 else:

2605 value = properties[property]['value']

2606 else:

2607 value = properties[property]['value']

2608 setattr(self, property, value)

2609

2610 def createMethods(self, classOrInstance, methods):

2611 class FunctionPool:

2612 def __init__(self,function):

2613 self.function = function

2614 def __getitem__(self,item):

2615 return partial(self.function,item)

2616

2617 @FunctionPool

2618 def innerMethod(staticArgs, *args):

2619 classOrInstance = staticArgs[0]

2620 methodDefinition = staticArgs[1]

2621 if methodDefinition['InParams'] is not None: 2621 ↛ 2769line 2621 didn't jump to line 2769, because the condition on line 2621 was never false

2622 if len(args) != len(methodDefinition['InParams']): 2622 ↛ 2623line 2622 didn't jump to line 2623, because the condition on line 2622 was never true

2623 LOG.error("Function called with %d parameters instead of %d!" % (len(args), len(methodDefinition['InParams'])))

2624 return None

2625 # In Params

2626 encodingUnit = ENCODING_UNIT()

2627

2628 inParams = OBJECT_BLOCK()

2629 inParams.structure += OBJECT_BLOCK.instanceType

2630 inParams['ObjectFlags'] = 2

2631 inParams['Decoration'] = b''

2632

2633 instanceType = INSTANCE_TYPE()

2634 instanceType['CurrentClass'] = b''

2635 instanceType['InstanceQualifierSet'] = b'\x04\x00\x00\x00\x01'

2636

2637 # Let's create the heap for the parameters

2638 instanceHeap = b''

2639 valueTable = b''

2640 parametersClass = ENCODED_STRING()

2641 parametersClass['Character'] = '__PARAMETERS'

2642 instanceHeap += parametersClass.getData()

2643 curHeapPtr = len(instanceHeap)

2644

2645 ndTable = 0

2646 for i in range(len(args)):

2647 paramDefinition = list(methodDefinition['InParams'].values())[i]

2648 inArg = args[i]

2649

2650 pType = paramDefinition['type'] & (~(CIM_ARRAY_FLAG|Inherited))

2651 if paramDefinition['type'] & CIM_ARRAY_FLAG: 2651 ↛ 2655line 2651 didn't jump to line 2655, because the condition on line 2651 was never true

2652 # Not yet ready

2653 #print paramDefinition

2654 #raise

2655 packStr = HEAPREF[:-2]

2656 else:

2657 packStr = CIM_TYPES_REF[pType][:-2]

2658

2659 if paramDefinition['type'] & CIM_ARRAY_FLAG: 2659 ↛ 2660line 2659 didn't jump to line 2660, because the condition on line 2659 was never true

2660 if inArg is None:

2661 valueTable += pack(packStr, 0)

2662 elif pType in (CIM_TYPE_ENUM.CIM_TYPE_STRING.value, CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value,

2663 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value, CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value):

2664 arraySize = pack(HEAPREF[:-2], len(inArg))

2665 arrayItems = []

2666 for j in range(len(inArg)):

2667 curVal = inArg[j]

2668 if pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2669 curObject = b''

2670 marshaledObject = curVal.marshalMe()

2671 curObject += pack('<L', marshaledObject['pObjectData']['ObjectEncodingLength'])

2672 curObject += marshaledObject['pObjectData']['ObjectBlock'].getData()

2673 arrayItems.append(curObject)

2674 continue

2675 strIn = ENCODED_STRING()

2676 if type(curVal) is str:

2677 # The Encoded-String-Flag is set to 0x01 if the sequence of characters that follows

2678 # consists of UTF-16 characters (as specified in [UNICODE]) followed by a UTF-16 null

2679 # terminator.

2680 strIn['Encoded_String_Flag'] = 0x1

2681 strIn.structure = strIn.tunicode

2682 strIn['Character'] = curVal.encode('utf-16le')

2683 else:

2684 strIn['Character'] = curVal

2685 arrayItems.append(strIn.getData())

2686

2687

2688 curStrHeapPtr = curHeapPtr + 4

2689 arrayHeapPtrValues = b''

2690 arrayValueTable = b''

2691 for j in range(len(arrayItems)):

2692 arrayHeapPtrValues += pack('<L', curStrHeapPtr + 4 * (len(arrayItems) - j) + len(arrayValueTable))

2693 arrayValueTable += arrayItems[j]

2694 curStrHeapPtr += 4

2695

2696 valueTable += pack('<L', curHeapPtr)

2697 instanceHeap += arraySize + arrayHeapPtrValues + arrayValueTable

2698 curHeapPtr = len(instanceHeap)

2699 else:

2700 arraySize = pack(HEAPREF[:-2], len(inArg))

2701 valueTable += pack('<L', curHeapPtr)

2702 instanceHeap += arraySize

2703 for curVal in inArg:

2704 instanceHeap += pack(packStr, curVal)

2705 curHeapPtr = len(instanceHeap)

2706 elif pType not in (CIM_TYPE_ENUM.CIM_TYPE_STRING.value, CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value,

2707 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value, CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value):

2708 valueTable += pack(packStr, inArg)

2709 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2710 if inArg is None: 2710 ↛ 2717line 2710 didn't jump to line 2717, because the condition on line 2710 was never false

2711 # For now we just pack None

2712 valueTable += b'\x00' * 4

2713 # The default property value is NULL, and it is

2714 # inherited from a parent class.

2715 ndTable |= 3 << (2 * i)

2716 else:

2717 valueTable += pack('<L', curHeapPtr)

2718 marshaledObject = inArg.marshalMe()

2719 instanceHeap += pack('<L', marshaledObject['pObjectData']['ObjectEncodingLength'])

2720 instanceHeap += marshaledObject['pObjectData']['ObjectBlock'].getData()

2721 curHeapPtr = len(instanceHeap)

2722 else:

2723 strIn = ENCODED_STRING()

2724 if type(inArg) is str: 2724 ↛ 2732line 2724 didn't jump to line 2732, because the condition on line 2724 was never false

2725 # The Encoded-String-Flag is set to 0x01 if the sequence of characters that follows

2726 # consists of UTF-16 characters (as specified in [UNICODE]) followed by a UTF-16 null

2727 # terminator.

2728 strIn['Encoded_String_Flag'] = 0x1

2729 strIn.structure = strIn.tunicode

2730 strIn['Character'] = inArg.encode('utf-16le')

2731 else:

2732 strIn['Character'] = inArg

2733 valueTable += pack('<L', curHeapPtr)

2734 instanceHeap += strIn.getData()

2735 curHeapPtr = len(instanceHeap)

2736

2737 ndTableLen = (len(args) - 1) // 4 + 1

2738

2739 packedNdTable = b''

2740 for i in range(ndTableLen):

2741 packedNdTable += pack('B', ndTable & 0xff)

2742 ndTable >>= 8

2743

2744 instanceType['NdTable_ValueTable'] = packedNdTable + valueTable

2745 heapRecord = HEAP()

2746 heapRecord['HeapLength'] = len(instanceHeap) | 0x80000000

2747 heapRecord['HeapItem'] = instanceHeap

2748

2749 instanceType['InstanceHeap'] = heapRecord

2750

2751 instanceType['EncodingLength'] = len(instanceType)

2752 inMethods = methodDefinition['InParamsRaw']['ClassType']['CurrentClass']['ClassPart']

2753 inMethods['ClassHeader']['EncodingLength'] = len(

2754 methodDefinition['InParamsRaw']['ClassType']['CurrentClass']['ClassPart'].getData())

2755 instanceType['CurrentClass'] = inMethods

2756

2757 inParams['InstanceType'] = instanceType.getData()

2758

2759 encodingUnit['ObjectBlock'] = inParams

2760 encodingUnit['ObjectEncodingLength'] = len(inParams)

2761

2762 objRefCustomIn = OBJREF_CUSTOM()

2763 objRefCustomIn['iid'] = self._iid

2764 objRefCustomIn['clsid'] = CLSID_WbemClassObject

2765 objRefCustomIn['cbExtension'] = 0

2766 objRefCustomIn['ObjectReferenceSize'] = len(encodingUnit)

2767 objRefCustomIn['pObjectData'] = encodingUnit

2768 else:

2769 objRefCustomIn = NULL

2770

2771 ### OutParams

2772 encodingUnit = ENCODING_UNIT()

2773

2774 outParams = OBJECT_BLOCK()

2775 outParams.structure += OBJECT_BLOCK.instanceType

2776 outParams['ObjectFlags'] = 2

2777 outParams['Decoration'] = b''

2778

2779 instanceType = INSTANCE_TYPE()

2780 instanceType['CurrentClass'] = b''

2781 instanceType['NdTable_ValueTable'] = b''

2782 instanceType['InstanceQualifierSet'] = b''

2783 instanceType['InstanceHeap'] = b''

2784 instanceType['EncodingLength'] = len(instanceType)

2785 instanceType['CurrentClass'] = methodDefinition['OutParamsRaw']['ClassType']['CurrentClass']['ClassPart'].getData()

2786 outParams['InstanceType'] = instanceType.getData()

2787

2788

2789 encodingUnit['ObjectBlock'] = outParams

2790 encodingUnit['ObjectEncodingLength'] = len(outParams)

2791

2792 objRefCustom = OBJREF_CUSTOM()

2793 objRefCustom['iid'] = self._iid

2794 objRefCustom['clsid'] = CLSID_WbemClassObject

2795 objRefCustom['cbExtension'] = 0

2796 objRefCustom['ObjectReferenceSize'] = len(encodingUnit)

2797 objRefCustom['pObjectData'] = encodingUnit

2798 try:

2799 return self.__iWbemServices.ExecMethod(classOrInstance, methodDefinition['name'], pInParams = objRefCustomIn )

2800 #return self.__iWbemServices.ExecMethod('Win32_Process.Handle="436"', methodDefinition['name'],

2801 # pInParams=objRefCustomIn).getObject().ctCurrent['properties']

2802 except Exception as e:

2803 if LOG.level == logging.DEBUG:

2804 import traceback

2805 traceback.print_exc()

2806 LOG.error(str(e))

2807

2808 for methodName in methods:

2809 innerMethod.__name__ = methodName

2810 setattr(self,innerMethod.__name__,innerMethod[classOrInstance,methods[methodName]])

2811 #methods = self.encodingUnit['ObjectBlock']

2812

2813

2814 class IWbemLoginClientID(IRemUnknown):

2815 def __init__(self, interface):

2816 IRemUnknown.__init__(self,interface)

2817 self._iid = IID_IWbemLoginClientID

2818

2819 def SetClientInfo(self, wszClientMachine, lClientProcId = 1234):

2820 request = IWbemLoginClientID_SetClientInfo()

2821 request['wszClientMachine'] = checkNullString(wszClientMachine)

2822 request['lClientProcId'] = lClientProcId

2823 request['lReserved'] = 0

2824 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2825 return resp

2826

2827 class IWbemLoginHelper(IRemUnknown):

2828 def __init__(self, interface):

2829 IRemUnknown.__init__(self,interface)

2830 self._iid = IID_IWbemLoginHelper

2831

2832 def SetEvent(self, sEventToSet):

2833 request = IWbemLoginHelper_SetEvent()

2834 request['sEventToSet'] = sEventToSet

2835 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2836 resp.dump()

2837 return resp

2838

2839

2840 class IWbemWCOSmartEnum(IRemUnknown):

2841 def __init__(self, interface):

2842 IRemUnknown.__init__(self,interface)

2843 self._iid = IID_IWbemWCOSmartEnum

2844

2845 def Next(self, proxyGUID, lTimeout, uCount):

2846 request = IWbemWCOSmartEnum_Next()

2847 request['proxyGUID'] = proxyGUID

2848 request['lTimeout'] = lTimeout

2849 request['uCount'] = uCount

2850 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2851 resp.dump()

2852 return resp

2853

2854 class IWbemFetchSmartEnum(IRemUnknown):

2855 def __init__(self, interface):

2856 IRemUnknown.__init__(self,interface)

2857 self._iid = IID_IWbemFetchSmartEnum

2858

2859 def GetSmartEnum(self, lTimeout):

2860 request = IWbemFetchSmartEnum_GetSmartEnum()

2861 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2862 resp.dump()

2863 return resp

2864

2865 class IWbemCallResult(IRemUnknown):

2866 def __init__(self, interface):

2867 IRemUnknown.__init__(self,interface)

2868 self._iid = IID_IWbemCallResult

2869

2870 def GetResultObject(self, lTimeout):

2871 request = IWbemCallResult_GetResultObject()

2872 request['lTimeout'] = lTimeout

2873 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2874 resp.dump()

2875 return resp

2876

2877 def GetResultString(self, lTimeout):

2878 request = IWbemCallResult_GetResultString()

2879 request['lTimeout'] = lTimeout

2880 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2881 resp.dump()

2882 return resp

2883

2884 def GetResultServices(self, lTimeout):

2885 request = IWbemCallResult_GetResultServices()

2886 request['lTimeout'] = lTimeout

2887 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2888 resp.dump()

2889 return resp

2890

2891 def GetCallStatus(self, lTimeout):

2892 request = IWbemCallResult_GetCallStatus()

2893 request['lTimeout'] = lTimeout

2894 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2895 return resp['plStatus']

2896

2897 class IEnumWbemClassObject(IRemUnknown):

2898 def __init__(self, interface, iWbemServices = None):

2899 IRemUnknown.__init__(self,interface)

2900 self._iid = IID_IEnumWbemClassObject

2901 self.__iWbemServices = iWbemServices

2902

2903 def Reset(self):

2904 request = IEnumWbemClassObject_Reset()

2905 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2906 resp.dump()

2907 return resp

2908

2909 def Next(self, lTimeout, uCount):

2910 request = IEnumWbemClassObject_Next()

2911 request['lTimeout'] = lTimeout

2912 request['uCount'] = uCount

2913 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2914 interfaces = list()

2915 for interface in resp['apObjects']:

2916 interfaces.append(IWbemClassObject(

2917 INTERFACE(self.get_cinstance(), b''.join(interface['abData']), self.get_ipidRemUnknown(),

2918 oxid=self.get_oxid(), target=self.get_target()), self.__iWbemServices))

2919

2920 return interfaces

2921

2922 def NextAsync(self, lTimeout, pSink):

2923 request = IEnumWbemClassObject_NextAsync()

2924 request['lTimeout'] = lTimeout

2925 request['pSink'] = pSink

2926 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2927 resp.dump()

2928 return resp

2929

2930 def Clone(self):

2931 request = IEnumWbemClassObject_Clone()

2932 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2933 resp.dump()

2934 return resp

2935

2936 def Skip(self, lTimeout, uCount):

2937 request = IEnumWbemClassObject_Skip()

2938 request['lTimeout'] = lTimeout

2939 request['uCount'] = uCount

2940 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2941 resp.dump()

2942 return resp

2943

2944 class IWbemServices(IRemUnknown):

2945 def __init__(self, interface):

2946 IRemUnknown.__init__(self,interface)

2947 self._iid = IID_IWbemServices

2948

2949 def OpenNamespace(self, strNamespace, lFlags=0, pCtx = NULL):

2950 request = IWbemServices_OpenNamespace()

2951 request['strNamespace']['asData'] = strNamespace

2952 request['lFlags'] = lFlags

2953 request['pCtx'] = pCtx

2954 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2955 resp.dump()

2956 return resp

2957

2958 def CancelAsyncCall(self,IWbemObjectSink ):

2959 request = IWbemServices_CancelAsyncCall()

2960 request['IWbemObjectSink'] = IWbemObjectSink

2961 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2962 return resp['ErrorCode']

2963

2964 def QueryObjectSink(self):

2965 request = IWbemServices_QueryObjectSink()

2966 request['lFlags'] = 0

2967 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2968 return INTERFACE(self.get_cinstance(), b''.join(resp['ppResponseHandler']['abData']), self.get_ipidRemUnknown(),

2969 target=self.get_target())

2970

2971 def GetObject(self, strObjectPath, lFlags=0, pCtx=NULL):

2972 request = IWbemServices_GetObject()

2973 request['strObjectPath']['asData'] = strObjectPath

2974 request['lFlags'] = lFlags

2975 request['pCtx'] = pCtx

2976 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2977 ppObject = IWbemClassObject(

2978 INTERFACE(self.get_cinstance(), b''.join(resp['ppObject']['abData']), self.get_ipidRemUnknown(),

2979 oxid=self.get_oxid(), target=self.get_target()), self)

2980 if resp['ppCallResult'] != NULL: 2980 ↛ 2985line 2980 didn't jump to line 2985, because the condition on line 2980 was never false

2981 ppcallResult = IWbemCallResult(

2982 INTERFACE(self.get_cinstance(), b''.join(resp['ppObject']['abData']), self.get_ipidRemUnknown(),

2983 target=self.get_target()))

2984 else:

2985 ppcallResult = NULL

2986 return ppObject, ppcallResult

2987

2988 def GetObjectAsync(self, strNamespace, lFlags=0, pCtx = NULL):

2989 request = IWbemServices_GetObjectAsync()

2990 request['strObjectPath']['asData'] = checkNullString(strNamespace)

2991 request['lFlags'] = lFlags

2992 request['pCtx'] = pCtx

2993 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

2994 resp.dump()

2995 return resp

2996

2997 def PutClass(self, pObject, lFlags=0, pCtx=NULL):

2998 request = IWbemServices_PutClass()

2999 request['pObject'] = pObject

3000 request['lFlags'] = lFlags

3001 request['pCtx'] = pCtx

3002 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3003 resp.dump()

3004 return resp

3005

3006 def PutClassAsync(self, pObject, lFlags=0, pCtx=NULL):

3007 request = IWbemServices_PutClassAsync()

3008 request['pObject'] = pObject

3009 request['lFlags'] = lFlags

3010 request['pCtx'] = pCtx

3011 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3012 resp.dump()

3013 return resp

3014

3015 def DeleteClass(self, strClass, lFlags=0, pCtx=NULL):

3016 request = IWbemServices_DeleteClass()

3017 request['strClass']['asData'] = checkNullString(strClass)

3018 request['lFlags'] = lFlags

3019 request['pCtx'] = pCtx

3020 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3021 resp.dump()

3022 return resp

3023

3024 def DeleteClassAsync(self, strClass, lFlags=0, pCtx=NULL):

3025 request = IWbemServices_DeleteClassAsync()

3026 request['strClass']['asData'] = checkNullString(strClass)

3027 request['lFlags'] = lFlags

3028 request['pCtx'] = pCtx

3029 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3030 resp.dump()

3031 return resp

3032

3033 def CreateClassEnum(self, strSuperClass, lFlags=0, pCtx=NULL):

3034 request = IWbemServices_CreateClassEnum()

3035 request['strSuperClass']['asData'] = checkNullString(strSuperClass)

3036 request['lFlags'] = lFlags

3037 request['pCtx'] = pCtx

3038 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3039 resp.dump()

3040 return resp

3041

3042 def CreateClassEnumAsync(self, strSuperClass, lFlags=0, pCtx=NULL):

3043 request = IWbemServices_CreateClassEnumAsync()

3044 request['strSuperClass']['asData'] = checkNullString(strSuperClass)

3045 request['lFlags'] = lFlags

3046 request['pCtx'] = pCtx

3047 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3048 resp.dump()

3049 return resp

3050

3051 def PutInstance(self, pInst, lFlags=0, pCtx=NULL):

3052 request = IWbemServices_PutInstance()

3053

3054 if pInst is NULL:

3055 request['pInst'] = pInst

3056 else:

3057 request['pInst']['ulCntData'] = len(pInst)

3058 request['pInst']['abData'] = list(pInst.getData())

3059 request['lFlags'] = lFlags

3060 request['pCtx'] = pCtx

3061 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3062 return IWbemCallResult(

3063 INTERFACE(self.get_cinstance(), b''.join(resp['ppCallResult']['abData']), self.get_ipidRemUnknown(),

3064 target=self.get_target()))

3065

3066 def PutInstanceAsync(self, pInst, lFlags=0, pCtx=NULL):

3067 request = IWbemServices_PutInstanceAsync()

3068 request['pInst'] = pInst

3069 request['lFlags'] = lFlags

3070 request['pCtx'] = pCtx

3071 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3072 resp.dump()

3073 return resp

3074

3075 def DeleteInstance(self, strObjectPath, lFlags=0, pCtx=NULL):

3076 request = IWbemServices_DeleteInstance()

3077 request['strObjectPath']['asData'] = checkNullString(strObjectPath)

3078 request['lFlags'] = lFlags

3079 request['pCtx'] = pCtx

3080 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3081 return IWbemCallResult(

3082 INTERFACE(self.get_cinstance(), b''.join(resp['ppCallResult']['abData']), self.get_ipidRemUnknown(),

3083 target=self.get_target()))

3084

3085 def DeleteInstanceAsync(self, strObjectPath, lFlags=0, pCtx=NULL):

3086 request = IWbemServices_DeleteInstanceAsync()

3087 request['strObjectPath']['asData'] = checkNullString(strObjectPath)

3088 request['lFlags'] = lFlags

3089 request['pCtx'] = pCtx

3090 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3091 resp.dump()

3092 return resp

3093

3094 def CreateInstanceEnum(self, strSuperClass, lFlags=0, pCtx=NULL):

3095 request = IWbemServices_CreateInstanceEnum()

3096 request['strSuperClass']['asData'] = strSuperClass

3097 request['lFlags'] = lFlags

3098 request['pCtx'] = pCtx

3099 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3100 resp.dump()

3101 return IEnumWbemClassObject(

3102 INTERFACE(self.get_cinstance(), b''.join(resp['ppEnum']['abData']), self.get_ipidRemUnknown(),

3103 target=self.get_target()))

3104

3105 def CreateInstanceEnumAsync(self, strSuperClass, lFlags=0, pCtx=NULL):

3106 request = IWbemServices_CreateInstanceEnumAsync()

3107 request['strSuperClass']['asData'] = checkNullString(strSuperClass)

3108 request['lFlags'] = lFlags

3109 request['pCtx'] = pCtx

3110 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3111 resp.dump()

3112 return resp

3113

3114 #def ExecQuery(self, strQuery, lFlags=WBEM_QUERY_FLAG_TYPE.WBEM_FLAG_PROTOTYPE, pCtx=NULL):

3115 def ExecQuery(self, strQuery, lFlags=0, pCtx=NULL):

3116 request = IWbemServices_ExecQuery()

3117 request['strQueryLanguage']['asData'] = checkNullString('WQL')

3118 request['strQuery']['asData'] = checkNullString(strQuery)

3119 request['lFlags'] = lFlags

3120 request['pCtx'] = pCtx

3121 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3122 return IEnumWbemClassObject(

3123 INTERFACE(self.get_cinstance(), b''.join(resp['ppEnum']['abData']), self.get_ipidRemUnknown(),

3124 target=self.get_target()), self)

3125

3126 def ExecQueryAsync(self, strQuery, lFlags=0, pCtx=NULL):

3127 request = IWbemServices_ExecQueryAsync()

3128 request['strQueryLanguage']['asData'] = checkNullString('WQL')

3129 request['strQuery']['asData'] = checkNullString(strQuery)

3130 request['lFlags'] = lFlags

3131 request['pCtx'] = pCtx

3132 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3133 resp.dump()

3134 return resp

3135

3136 def ExecNotificationQuery(self, strQuery, lFlags=0, pCtx=NULL):

3137 request = IWbemServices_ExecNotificationQuery()

3138 request['strQueryLanguage']['asData'] = checkNullString('WQL')

3139 request['strQuery']['asData'] = checkNullString(strQuery)

3140 request['lFlags'] = lFlags

3141 request['pCtx'] = pCtx

3142 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3143 return IEnumWbemClassObject(

3144 INTERFACE(self.get_cinstance(), b''.join(resp['ppEnum']['abData']), self.get_ipidRemUnknown(),

3145 target=self.get_target()), self)

3146

3147 def ExecNotificationQueryAsync(self, strQuery, lFlags=0, pCtx=NULL):

3148 request = IWbemServices_ExecNotificationQueryAsync()

3149 request['strQueryLanguage']['asData'] = checkNullString('WQL')

3150 request['strQuery']['asData'] = checkNullString(strQuery)

3151 request['lFlags'] = lFlags

3152 request['pCtx'] = pCtx

3153 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3154 resp.dump()

3155 return resp

3156

3157 def ExecMethod(self, strObjectPath, strMethodName, lFlags=0, pCtx=NULL, pInParams=NULL, ppOutParams = NULL):

3158 request = IWbemServices_ExecMethod()

3159 request['strObjectPath']['asData'] = checkNullString(strObjectPath)

3160 request['strMethodName']['asData'] = checkNullString(strMethodName)

3161 request['lFlags'] = lFlags

3162 request['pCtx'] = pCtx

3163 if pInParams is NULL: 3163 ↛ 3164line 3163 didn't jump to line 3164, because the condition on line 3163 was never true

3164 request['pInParams'] = pInParams

3165 else:

3166 request['pInParams']['ulCntData'] = len(pInParams)

3167 request['pInParams']['abData'] = list(pInParams.getData())

3168

3169 request.fields['ppCallResult'] = NULL

3170 if ppOutParams is NULL: 3170 ↛ 3173line 3170 didn't jump to line 3173, because the condition on line 3170 was never false

3171 request.fields['ppOutParams'].fields['Data'] = NULL

3172 else:

3173 request['ppOutParams']['ulCntData'] = len(ppOutParams.getData())

3174 request['ppOutParams']['abData'] = list(ppOutParams.getData())

3175 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3176 return IWbemClassObject(

3177 INTERFACE(self.get_cinstance(), b''.join(resp['ppOutParams']['abData']), self.get_ipidRemUnknown(),

3178 oxid=self.get_oxid(), target=self.get_target()))

3179

3180 def ExecMethodAsync(self, strObjectPath, strMethodName, lFlags=0, pCtx=NULL, pInParams=NULL):

3181 request = IWbemServices_ExecMethodAsync()

3182 request['strObjectPath']['asData'] = checkNullString(strObjectPath)

3183 request['strMethodName']['asData'] = checkNullString(strMethodName)

3184 request['lFlags'] = lFlags

3185 request['pCtx'] = pCtx

3186 request['pInParams'] = pInParams

3187 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3188 resp.dump()

3189 return resp

3190

3191 class IWbemLevel1Login(IRemUnknown):

3192 def __init__(self, interface):

3193 IRemUnknown.__init__(self,interface)

3194 self._iid = IID_IWbemLevel1Login

3195

3196 def EstablishPosition(self):

3197 request = IWbemLevel1Login_EstablishPosition()

3198 request['reserved1'] = NULL

3199 request['reserved2'] = 0

3200 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3201 return resp['LocaleVersion']

3202

3203 def RequestChallenge(self):

3204 request = IWbemLevel1Login_RequestChallenge()

3205 request['reserved1'] = NULL

3206 request['reserved2'] = NULL

3207 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3208 return resp['reserved3']

3209

3210 def WBEMLogin(self):

3211 request = IWbemLevel1Login_WBEMLogin()

3212 request['reserved1'] = NULL

3213 request['reserved2'] = NULL

3214 request['reserved3'] = 0

3215 request['reserved4'] = NULL

3216 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3217 return resp['reserved5']

3218

3219 def NTLMLogin(self, wszNetworkResource, wszPreferredLocale, pCtx):

3220 request = IWbemLevel1Login_NTLMLogin()

3221 request['wszNetworkResource'] = checkNullString(wszNetworkResource)

3222 request['wszPreferredLocale'] = checkNullString(wszPreferredLocale)

3223 request['lFlags'] = 0

3224 request['pCtx'] = pCtx

3225 resp = self.request(request, iid = self._iid, uuid = self.get_iPid())

3226 return IWbemServices(

3227 INTERFACE(self.get_cinstance(), b''.join(resp['ppNamespace']['abData']), self.get_ipidRemUnknown(),

3228 target=self.get_target()))

3229

3230

3231 if __name__ == '__main__': 3231 ↛ 3233line 3231 didn't jump to line 3233, because the condition on line 3231 was never true

3232 # Example 1

3233 baseClass = b'xV4\x12\xd0\x00\x00\x00\x05\x00DPRAVAT-DEV\x00\x00ROOT\x00\x1d\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80f\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\n\x00\x00\x00\x05\xff\xff\xff\xff<\x00\x00\x80\x00Base\x00\x00Id\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x004\x00\x00\x00\x01\x00\x00\x80\x13\x0b\x00\x00\x00\xff\xff\x00sint32\x00\x0c\x00\x00\x00\x00\x004\x00\x00\x00\x00\x80\x00\x80\x13\x0b\x00\x00\x00\xff\xff\x00sint32\x00'

3234

3235 #encodingUnit = ENCODING_UNIT(baseClass)

3236 #encodingUnit.dump()

3237 #encodingUnit['ObjectBlock'].printInformation()

3238 #print "LEN ", len(baseClass), len(encodingUnit)

3239

3240 #myClass = b"xV4\x12.\x02\x00\x00\x05\x00DPRAVAT-DEV\x00\x00ROOT\x00f\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x00\x06\x00\x00\x00\n\x00\x00\x00\x05\xff\xff\xff\xff<\x00\x00\x80\x00Base\x00\x00Id\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x004\x00\x00\x00\x01\x00\x00\x80\x13\x0b\x00\x00\x00\xff\xff\x00sint32\x00\x0c\x00\x00\x00\x00\x004\x00\x00\x00\x00\x80v\x01\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x0e\x00\x00\x00\x00Base\x00\x06\x00\x00\x00\x11\x00\x00\x00\t\x00\x00\x00\x00\x08\x00\x00\x00\x16\x00\x00\x00\x04\x00\x00\x00'\x00\x00\x00.\x00\x00\x00U\x00\x00\x00\\\x00\x00\x00\x99\x00\x00\x00\xa0\x00\x00\x00\xc7\x00\x00\x00\xcb\x00\x00\x00G\xff\xff\xff\xff\xff\xff\xff\xff\xfd\x00\x00\x00\xff\xff\xff\xff\x11\x01\x00\x80\x00MyClass\x00\x00Description\x00\x00MyClass Example\x00\x00Array\x00\x13 \x00\x00\x03\x00\x0c\x00\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00M\x00\x00\x00\x00uint32\x00\x00Data1\x00\x08\x00\x00\x00\x01\x00\x04\x00\x00\x00\x01\x00\x00\x00'\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00\x91\x00\x00\x00\x03\x00\x00\x80\x00\x0b\x00\x00\x00\xff\xff\x04\x00\x00\x80\x00\x0b\x00\x00\x00\xff\xff\x00string\x00\x00Data2\x00\x08\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00\xbf\x00\x00\x00\x00string\x00\x00Id\x00\x03@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\n\x00\x00\x80#\x08\x00\x00\x00\xf5\x00\x00\x00\x01\x00\x00\x803\x0b\x00\x00\x00\xff\xff\x00sint32\x00\x00defaultValue\x00\x00\x00\x00\x00\x00\x00\x0c\x00\x00\x00\x00\x00\x00s\x00\x00\x00\x802\x00\x00defaultValue\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00"

3241 #hexdump(myClass)

3242 #encodingUnit = ENCODING_UNIT(myClass)

3243 #print "LEN ", len(myClass), len(encodingUnit)

3244 #encodingUnit.dump()

3245 #encodingUnit['ObjectBlock'].printInformation()

3246

3247 #instanceMyClass = b"xV4\x12\xd3\x01\x00\x00\x06\x00DPRAVAT-DEV\x00\x00ROOT\x00v\x01\x00\x00\x00\x00\x00\x00\x00\x11\x00\x00\x00\x0e\x00\x00\x00\x00Base\x00\x06\x00\x00\x00\x11\x00\x00\x00\t\x00\x00\x00\x00\x08\x00\x00\x00\x16\x00\x00\x00\x04\x00\x00\x00'\x00\x00\x00.\x00\x00\x00U\x00\x00\x00\\\x00\x00\x00\x99\x00\x00\x00\xa0\x00\x00\x00\xc7\x00\x00\x00\xcb\x00\x00\x00G\xff\xff\xff\xff\xff\xff\xff\xff\xfd\x00\x00\x00\xff\xff\xff\xff\x11\x01\x00\x80\x00MyClass\x00\x00Description\x00\x00MyClass Example\x00\x00Array\x00\x13 \x00\x00\x03\x00\x0c\x00\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00M\x00\x00\x00\x00uint32\x00\x00Data1\x00\x08\x00\x00\x00\x01\x00\x04\x00\x00\x00\x01\x00\x00\x00'\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00\x91\x00\x00\x00\x03\x00\x00\x80\x00\x0b\x00\x00\x00\xff\xff\x04\x00\x00\x80\x00\x0b\x00\x00\x00\xff\xff\x00string\x00\x00Data2\x00\x08\x00\x00\x00\x02\x00\x08\x00\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\n\x00\x00\x80\x03\x08\x00\x00\x00\xbf\x00\x00\x00\x00string\x00\x00Id\x00\x03@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\n\x00\x00\x80#\x08\x00\x00\x00\xf5\x00\x00\x00\x01\x00\x00\x803\x0b\x00\x00\x00\xff\xff\x00sint32\x00\x00defaultValue\x00\x00\x00\x00\x00\x00\x00I\x00\x00\x00\x00\x00\x00\x00\x00 {\x00\x00\x00\x19\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x04\x00\x00\x00\x01&\x00\x00\x80\x00MyClass\x00\x03\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x00StringField\x00"

3248 #encodingUnit = ENCODING_UNIT(instanceMyClass)

3249 #encodingUnit.dump()

3250 #encodingUnit['ObjectBlock'].printInformation()