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

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

## 1771 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# Impacket - Collection of Python classes for working with network protocols.

2#

3# SECUREAUTH LABS. Copyright (C) 2021 SecureAuth Corporation. All rights reserved.

4#

5# This software is provided under a slightly modified version

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

7# for more information.

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# Author:

21# Alberto Solino (@agsolino)

22#

23 from __future__ import division

24 from __future__ import print_function

25 from struct import unpack, calcsize, pack

26 from functools import partial

27 import collections

28 import logging

29 import six

30

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

32 NDRENUM

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

34 PMInterfacePointer_ARRAY, BYTE_ARRAY, PPMInterfacePointer, OBJREF_CUSTOM

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

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

37 from impacket.dcerpc.v5.enum import Enum

38 from impacket.dcerpc.v5.rpcrt import DCERPCException

39 from impacket import hresult_errors, LOG

40 from impacket.uuid import string_to_bin, uuidtup_to_bin

41 from impacket.structure import Structure, hexdump

42

43

44 def format_structure(d, level=0):

45 x = ""

46 if isinstance(d, collections.Mapping):

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

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

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

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

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

52 for e in d:

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

54 else:

55 x = str(d)

56 return x

57 try:

58 from collections import OrderedDict

59 except:

60 try:

61 from ordereddict.ordereddict import OrderedDict

62 except:

63 from ordereddict import OrderedDict

64

65 class DCERPCSessionError(DCERPCException):

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

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

68

69 def __str__( self ):

70 if self.error_code in hresult_errors.ERROR_MESSAGES:

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

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

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

74 else:

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

76 try:

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

78 except:

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

80

81################################################################################

82# WMIO Structures and Constants

83################################################################################

84 WBEM_FLAVOR_FLAG_PROPAGATE_O_INSTANCE = 0x01

85 WBEM_FLAVOR_FLAG_PROPAGATE_O_DERIVED_CLASS = 0x02

86 WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10

87 WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20

88 WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40

89 WBEM_FLAVOR_AMENDED = 0x80

90

91# 2.2.6 ObjectFlags

92 OBJECT_FLAGS = 'B=0'

93

94#2.2.77 Signature

95 SIGNATURE = '<L=0x12345678'

96

97# 2.2.4 ObjectEncodingLength

98 OBJECT_ENCODING_LENGTH = '<L=0'

99

100# 2.2.73 EncodingLength

101 ENCODING_LENGTH = '<L=0'

102

103# 2.2.78 Encoded-String

104 ENCODED_STRING_FLAG = 'B=0'

105

106# 2.2.76 ReservedOctet

107 RESERVED_OCTET = 'B=0'

108

109# 2.2.28 NdTableValueTableLength

110 NDTABLE_VALUE_TABLE_LENGTH = '<L=0'

111

112# 2.2.80 DictionaryReference

113 DICTIONARY_REFERENCE = {

114 0 : '"',

115 1 : 'key',

116 2 : 'NADA',

117 3 : 'read',

118 4 : 'write',

119 5 : 'volatile',

120 6 : 'provider',

121 7 : 'dynamic',

122 8 : 'cimwin32',

123 9 : 'DWORD',

124 10 : 'CIMTYPE',

125}

126

127 class ENCODED_STRING(Structure):

128 commonHdr = (

129 ('Encoded_String_Flag', ENCODED_STRING_FLAG),

130 )

131

132 tascii = (

133 ('Character', 'z'),

134 )

135

136 tunicode = (

137 ('Character', 'u'),

138 )

139

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

141 Structure.__init__(self, data, alignment)

142 if data is not None:

143 # Let's first check the commonHdr

144 self.fromString(data)

145 self.structure = ()

146 self.isUnicode = False

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

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

149 self.structure += self.tascii

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

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

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

153 else:

154 self.structure = self.tunicode

155 self.isUnicode = True

156

157 self.fromString(data)

158 else:

159 self.structure = self.tascii

160 self.data = None

161

162 def __getitem__(self, key):

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

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

165 return Structure.__getitem__(self, key)

166

167

168# 2.2.8 DecServerName

169 DEC_SERVER_NAME = ENCODED_STRING

170

171# 2.2.9 DecNamespaceName

172 DEC_NAMESPACE_NAME = ENCODED_STRING

173

174# 2.2.7 Decoration

175 class DECORATION(Structure):

176 structure = (

177 ('DecServerName', ':', DEC_SERVER_NAME),

178 ('DecNamespaceName', ':', DEC_NAMESPACE_NAME),

179 )

180

181# 2.2.69 HeapRef

182 HEAPREF = '<L=0'

183

184# 2.2.68 HeapStringRef

185 HEAP_STRING_REF = HEAPREF

186

187# 2.2.19 ClassNameRef

188 CLASS_NAME_REF = HEAP_STRING_REF

189

190# 2.2.16 ClassHeader

191 class CLASS_HEADER(Structure):

192 structure = (

193 ('EncodingLength', ENCODING_LENGTH),

194 ('ReservedOctet', RESERVED_OCTET),

195 ('ClassNameRef', CLASS_NAME_REF),

196 ('NdTableValueTableLength', NDTABLE_VALUE_TABLE_LENGTH),

197 )

198

199# 2.2.17 DerivationList

200 class DERIVATION_LIST(Structure):

201 structure = (

202 ('EncodingLength', ENCODING_LENGTH),

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

204 ('ClassNameEncoding', ':'),

205 )

206

207# 2.2.82 CimType

208 CIM_TYPE = '<L=0'

209 CIM_ARRAY_FLAG = 0x2000

210

211 class EnumType(type):

212 def __getattr__(self, attr):

213 return self.enumItems[attr].value

214

215 class CIM_TYPE_ENUM(Enum):

216# __metaclass__ = EnumType

217 CIM_TYPE_SINT8 = 16

218 CIM_TYPE_UINT8 = 17

219 CIM_TYPE_SINT16 = 2

220 CIM_TYPE_UINT16 = 18

221 CIM_TYPE_SINT32 = 3

222 CIM_TYPE_UINT32 = 19

223 CIM_TYPE_SINT64 = 20

224 CIM_TYPE_UINT64 = 21

225 CIM_TYPE_REAL32 = 4

226 CIM_TYPE_REAL64 = 5

227 CIM_TYPE_BOOLEAN = 11

228 CIM_TYPE_STRING = 8

229 CIM_TYPE_DATETIME = 101

230 CIM_TYPE_REFERENCE = 102

231 CIM_TYPE_CHAR16 = 103

232 CIM_TYPE_OBJECT = 13

233 CIM_ARRAY_SINT8 = 8208

234 CIM_ARRAY_UINT8 = 8209

235 CIM_ARRAY_SINT16 = 8194

236 CIM_ARRAY_UINT16 = 8210

237 CIM_ARRAY_SINT32 = 8195

238 CIM_ARRAY_UINT32 = 8201

239 CIM_ARRAY_SINT64 = 8202

240 CIM_ARRAY_UINT64 = 8203

241 CIM_ARRAY_REAL32 = 8196

242 CIM_ARRAY_REAL64 = 8197

243 CIM_ARRAY_BOOLEAN = 8203

244 CIM_ARRAY_STRING = 8200

245 CIM_ARRAY_DATETIME = 8293

246 CIM_ARRAY_REFERENCE = 8294

247 CIM_ARRAY_CHAR16 = 8295

248 CIM_ARRAY_OBJECT = 8205

249

250 CIM_TYPES_REF = {

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

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

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

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

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

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

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

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

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

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

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

262 CIM_TYPE_ENUM.CIM_TYPE_STRING.value : HEAPREF,

263 CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value : HEAPREF,

264 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value: HEAPREF,

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

266 CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value : HEAPREF,

267}

268

269 CIM_TYPE_TO_NAME = {

270 CIM_TYPE_ENUM.CIM_TYPE_SINT8.value : 'sint8',

271 CIM_TYPE_ENUM.CIM_TYPE_UINT8.value : 'uint8',

272 CIM_TYPE_ENUM.CIM_TYPE_SINT16.value : 'sint16',

273 CIM_TYPE_ENUM.CIM_TYPE_UINT16.value : 'uint16',

274 CIM_TYPE_ENUM.CIM_TYPE_SINT32.value : 'sint32',

275 CIM_TYPE_ENUM.CIM_TYPE_UINT32.value : 'uint32',

276 CIM_TYPE_ENUM.CIM_TYPE_SINT64.value : 'sint64',

277 CIM_TYPE_ENUM.CIM_TYPE_UINT64.value : 'uint64',

278 CIM_TYPE_ENUM.CIM_TYPE_REAL32.value : 'real32',

279 CIM_TYPE_ENUM.CIM_TYPE_REAL64.value : 'real64',

280 CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value : 'bool',

281 CIM_TYPE_ENUM.CIM_TYPE_STRING.value : 'string',

282 CIM_TYPE_ENUM.CIM_TYPE_DATETIME.value : 'datetime',

283 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value: 'reference',

284 CIM_TYPE_ENUM.CIM_TYPE_CHAR16.value : 'char16',

285 CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value : 'object',

286}

287

288 CIM_NUMBER_TYPES = (

289 CIM_TYPE_ENUM.CIM_TYPE_CHAR16.value, CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value,

290 CIM_TYPE_ENUM.CIM_TYPE_SINT8.value, CIM_TYPE_ENUM.CIM_TYPE_UINT8.value,

291 CIM_TYPE_ENUM.CIM_TYPE_SINT16.value, CIM_TYPE_ENUM.CIM_TYPE_UINT16.value,

292 CIM_TYPE_ENUM.CIM_TYPE_SINT32.value, CIM_TYPE_ENUM.CIM_TYPE_UINT32.value,

293 CIM_TYPE_ENUM.CIM_TYPE_SINT64.value, CIM_TYPE_ENUM.CIM_TYPE_UINT64.value,

294 CIM_TYPE_ENUM.CIM_TYPE_REAL32.value, CIM_TYPE_ENUM.CIM_TYPE_REAL64.value,

295)

296

297# 2.2.61 QualifierName

298 QUALIFIER_NAME = HEAP_STRING_REF

299

300# 2.2.62 QualifierFlavor

301 QUALIFIER_FLAVOR = 'B=0'

302

303# 2.2.63 QualifierType

304 QUALIFIER_TYPE = CIM_TYPE

305

306# 2.2.71 EncodedValue

307 class ENCODED_VALUE(Structure):

308 structure = (

309 ('QualifierName', QUALIFIER_NAME),

310 )

311

312 @classmethod

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

314 # Let's get the default Values

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

316

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

318 heapData = heap[entry:]

319 if cimType & CIM_ARRAY_FLAG:

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

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

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

323 heapData = heapData[dataSize:]

324 array = list()

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

326 dataSizeArray = calcsize(unpackStrArray)

327 if cimType == CIM_TYPE_ENUM.CIM_ARRAY_STRING.value:

328 # We have an array of strings

329 # First items are DWORDs with the string pointers

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

331 heapData = heapData[4*numItems:]

332 # Let's now grab the strings

333 for _ in range(numItems):

334 item = ENCODED_STRING(heapData)

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

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

337 elif cimType == CIM_TYPE_ENUM.CIM_ARRAY_OBJECT.value: 337 ↛ 339line 337 didn't jump to line 339, because the condition on line 337 was never true

338 # Discard the pointers

339 heapData = heapData[dataSize*numItems:]

340 for item in range(numItems):

341 msb = METHOD_SIGNATURE_BLOCK(heapData)

342 unit = ENCODING_UNIT()

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

344 unit['ObjectBlock'] = msb['ObjectBlock']

345 array.append(unit)

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

347 else:

348 for item in range(numItems):

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

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

351 heapData = heapData[dataSizeArray:]

352 value = array

353 elif pType == CIM_TYPE_ENUM.CIM_TYPE_BOOLEAN.value:

354 if entry == 0xffff:

355 value = 'True'

356 else:

357 value = 'False'

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

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

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

361

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

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

364 msb = METHOD_SIGNATURE_BLOCK(heapData)

365 unit = ENCODING_UNIT()

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

367 unit['ObjectBlock'] = msb['ObjectBlock']

368 value = unit

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

370 CIM_TYPE_ENUM.CIM_TYPE_REFERENCE.value):

371 value = entry

372 else:

373 try:

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

375 except UnicodeDecodeError:

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

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

378 hexdump(heapData)

379 raise

380

381 return value

382

383# 2.2.64 QualifierValue

384 QUALIFIER_VALUE = ENCODED_VALUE

385

386# 2.2.60 Qualifier

387 class QUALIFIER(Structure):

388 commonHdr = (

389 ('QualifierName', QUALIFIER_NAME),

390 ('QualifierFlavor', QUALIFIER_FLAVOR),

391 ('QualifierType', QUALIFIER_TYPE),

392 )

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

394 Structure.__init__(self, data, alignment)

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

396 # Let's first check the commonHdr

397 self.fromString(data)

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

399 self.fromString(data)

400 else:

401 self.data = None

402

403# 2.2.59 QualifierSet

404 class QUALIFIER_SET(Structure):

405 structure = (

406 ('EncodingLength', ENCODING_LENGTH),

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

408 ('Qualifier', ':'),

409 )

410

411 def getQualifiers(self, heap):

412 data = self['Qualifier']

413 qualifiers = dict()

414 while len(data) > 0:

415 itemn = QUALIFIER(data)

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

417 qName = b''

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

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

420 else:

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

422

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

424 qualifiers[qName] = value

425 data = data[len(itemn):]

426

427 return qualifiers

428

429# 2.2.20 ClassQualifierSet

430 CLASS_QUALIFIER_SET = QUALIFIER_SET

431

432# 2.2.22 PropertyCount

433 PROPERTY_COUNT = '<L=0'

434

435# 2.2.24 PropertyNameRef

436 PROPERTY_NAME_REF = HEAP_STRING_REF

437

438# 2.2.25 PropertyInfoRef

439 PROPERTY_INFO_REF = HEAPREF

440

441# 2.2.23 PropertyLookup

442 class PropertyLookup(Structure):

443 structure = (

444 ('PropertyNameRef', PROPERTY_NAME_REF),

445 ('PropertyInfoRef', PROPERTY_INFO_REF),

446 )

447

448# 2.2.31 PropertyType

449 PROPERTY_TYPE = '<L=0'

450

451# 2.2.33 DeclarationOrder

452 DECLARATION_ORDER = '<H=0'

453

454# 2.2.34 ValueTableOffset

455 VALUE_TABLE_OFFSET = '<L=0'

456

457# 2.2.35 ClassOfOrigin

458 CLASS_OF_ORIGIN = '<L=0'

459

460# 2.2.36 PropertyQualifierSet

461 PROPERTY_QUALIFIER_SET = QUALIFIER_SET

462

463# 2.2.30 PropertyInfo

464 class PROPERTY_INFO(Structure):

465 structure = (

466 ('PropertyType', PROPERTY_TYPE),

467 ('DeclarationOrder', DECLARATION_ORDER),

468 ('ValueTableOffset', VALUE_TABLE_OFFSET),

469 ('ClassOfOrigin', CLASS_OF_ORIGIN),

470 ('PropertyQualifierSet', ':', PROPERTY_QUALIFIER_SET),

471 )

472

473# 2.2.32 Inherited

474 Inherited = 0x4000

475

476# 2.2.21 PropertyLookupTable

477 class PROPERTY_LOOKUP_TABLE(Structure):

478 PropertyLookupSize = len(PropertyLookup())

479 structure = (

480 ('PropertyCount', PROPERTY_COUNT),

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

482 ('PropertyLookup', ':'),

483 )

484

485 def getProperties(self, heap):

486 propTable = self['PropertyLookup']

487 properties = dict()

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

489 propItemDict = dict()

490 propItem = PropertyLookup(propTable)

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

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

493 else:

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

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

496 pType = propInfo['PropertyType']

497 pType &= (~CIM_ARRAY_FLAG)

498 pType &= (~Inherited)

499 sType = CIM_TYPE_TO_NAME[pType]

500

501 propItemDict['stype'] = sType

502 propItemDict['name'] = propName

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

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

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

506 propItemDict['value'] = None

507

508 qualifiers = dict()

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

510 while len(qualifiersBuf) > 0:

511 record = QUALIFIER(qualifiersBuf)

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

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

514 else:

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

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

517 qualifiersBuf = qualifiersBuf[len(record):]

518 qualifiers[qualifierName] = qualifierValue

519

520 propItemDict['qualifiers'] = qualifiers

521 properties[propName] = propItemDict

522

523 propTable = propTable[self.PropertyLookupSize:]

524

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

526 #return properties

527

528# 2.2.66 Heap

529 HEAP_LENGTH = '<L=0'

530

531 class HEAP(Structure):

532 structure = (

533 ('HeapLength', HEAP_LENGTH),

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

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

536 # length is actually only 31 bits.

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

538 ('HeapItem', ':'),

539 )

540

541# 2.2.37 ClassHeap

542 CLASS_HEAP = HEAP

543

544# 2.2.15 ClassPart

545 class CLASS_PART(Structure):

546 commonHdr = (

547 ('ClassHeader', ':', CLASS_HEADER),

548 ('DerivationList', ':', DERIVATION_LIST),

549 ('ClassQualifierSet', ':', CLASS_QUALIFIER_SET),

550 ('PropertyLookupTable', ':', PROPERTY_LOOKUP_TABLE),

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

552 ('NdTable_ValueTable',':'),

553 ('ClassHeap', ':', CLASS_HEAP),

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

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

556 )

557 def getQualifiers(self):

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

559

560 def getProperties(self):

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

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

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

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

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

566 for key in sorted_props:

567 # Let's get the default Values

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

569 if properties[key]['type'] & CIM_ARRAY_FLAG:

570 unpackStr = HEAPREF[:-2]

571 else:

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

573 dataSize = calcsize(unpackStr)

574 try:

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

576 except:

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

578 itemValue = 0xffffffff

579

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

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

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

583 valueTable = valueTable[dataSize:]

584 return properties

585

586# 2.2.39 MethodCount

587 METHOD_COUNT = '<H=0'

588

589# 2.2.40 MethodCountPadding

590 METHOD_COUNT_PADDING = '<H=0'

591

592# 2.2.42 MethodName

593 METHOD_NAME = HEAP_STRING_REF

594

595# 2.2.43 MethodFlags

596 METHOD_FLAGS = 'B=0'

597

598# 2.2.44 MethodPadding

599 METHOD_PADDING = "3s=b''"

600

601# 2.2.45 MethodOrigin

602 METHOD_ORIGIN = '<L=0'

603

604# 2.2.47 HeapQualifierSetRef

605 HEAP_QUALIFIER_SET_REF = HEAPREF

606

607# 2.2.46 MethodQualifiers

608 METHOD_QUALIFIERS = HEAP_QUALIFIER_SET_REF

609

610# 2.2.51 HeapMethodSignatureBlockRef

611 HEAP_METHOD_SIGNATURE_BLOCK_REF = HEAPREF

612

613# 2.2.50 MethodSignature

614 METHOD_SIGNATURE = HEAP_METHOD_SIGNATURE_BLOCK_REF

615

616# 2.2.48 InputSignature

617 INPUT_SIGNATURE = METHOD_SIGNATURE

618

619# 2.2.49 OutputSignature

620 OUTPUT_SIGNATURE = METHOD_SIGNATURE

621

622# 2.2.52 MethodHeap

623 METHOD_HEAP = HEAP

624

625# 2.2.41 MethodDescription

626 class METHOD_DESCRIPTION(Structure):

627 structure = (

628 ('MethodName',METHOD_NAME),

629 ('MethodFlags', METHOD_FLAGS),

630 ('MethodPadding', METHOD_PADDING),

631 ('MethodOrigin', METHOD_ORIGIN),

632 ('MethodQualifiers', METHOD_QUALIFIERS),

633 ('InputSignature', INPUT_SIGNATURE),

634 ('OutputSignature', OUTPUT_SIGNATURE),

635 )

636

637# 2.2.38 MethodsPart

638 class METHODS_PART(Structure):

639 MethodDescriptionSize = len(METHOD_DESCRIPTION())

640 structure = (

641 ('EncodingLength',ENCODING_LENGTH),

642 ('MethodCount', METHOD_COUNT),

643 ('MethodCountPadding', METHOD_COUNT_PADDING),

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

645 ('MethodDescription', ':'),

646 ('MethodHeap', ':', METHOD_HEAP),

647 )

648

649 def getMethods(self):

650 methods = OrderedDict()

651 data = self['MethodDescription']

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

653

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

655 methodDict = OrderedDict()

656 itemn = METHOD_DESCRIPTION(data)

657 if itemn['MethodFlags'] & WBEM_FLAVOR_ORIGIN_PROPAGATED: 657 ↛ 661line 657 didn't jump to line 661, because the condition on line 657 was never true

658 # ToDo

659 #print "WBEM_FLAVOR_ORIGIN_PROPAGATED not yet supported!"

660 #raise

661 pass

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

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

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

665 # There are qualifiers

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

667 qualifiers = qualifiersSet.getQualifiers(heap)

668 methodDict['qualifiers'] = qualifiers

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

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

671 if inputSignature['EncodingLength'] > 0:

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

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

674 #print methodDict['InParams']

675 else:

676 methodDict['InParams'] = None

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

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

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

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

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

682 else:

683 methodDict['OutParams'] = None

684 data = data[len(itemn):]

685 methods[methodDict['name']] = methodDict

686

687 return methods

688

689# 2.2.14 ClassAndMethodsPart

690 class CLASS_AND_METHODS_PART(Structure):

691 structure = (

692 ('ClassPart', ':', CLASS_PART),

693 ('MethodsPart', ':', METHODS_PART),

694 )

695

696 def getClassName(self):

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

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

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

700 return 'None'

701 else:

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

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

704 while len(derivationList) > 0:

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

706 className += ' : %s ' % superClass

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

708 return className

709

710 def getQualifiers(self):

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

712

713 def getProperties(self):

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

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

716

717 def getMethods(self):

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

719

720# 2.2.13 CurrentClass

721 CURRENT_CLASS = CLASS_AND_METHODS_PART

722

723# 2.2.54 InstanceFlags

724 INSTANCE_FLAGS = 'B=0'

725

726# 2.2.55 InstanceClassName

727 INSTANCE_CLASS_NAME = HEAP_STRING_REF

728

729# 2.2.27 NullAndDefaultFlag

730 NULL_AND_DEFAULT_FLAG = 'B=0'

731

732# 2.2.26 NdTable

733 NDTABLE = NULL_AND_DEFAULT_FLAG

734

735# 2.2.56 InstanceData

736#InstanceData = ValueTable

737

738 class CURRENT_CLASS_NO_METHODS(CLASS_AND_METHODS_PART):

739 structure = (

740 ('ClassPart', ':', CLASS_PART),

741 )

742 def getMethods(self):

743 return ()

744

745# 2.2.65 InstancePropQualifierSet

746 INST_PROP_QUAL_SET_FLAG = 'B=0'

747 class INSTANCE_PROP_QUALIFIER_SET(Structure):

748 commonHdr = (

749 ('InstPropQualSetFlag', INST_PROP_QUAL_SET_FLAG),

750 )

751 tail = (

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

753 #('QualifierSet', ':', QualifierSet),

754 ('QualifierSet', ':', QUALIFIER_SET),

755 )

756

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

758 Structure.__init__(self, data, alignment)

759 self.structure = ()

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

761 # Let's first check the commonHdr

762 self.fromString(data)

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

764 # We don't support this yet!

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

766 self.fromString(data)

767 else:

768 self.data = None

769

770# 2.2.57 InstanceQualifierSet

771 class INSTANCE_QUALIFIER_SET(Structure):

772 structure = (

773 ('QualifierSet', ':', QUALIFIER_SET),

774 ('InstancePropQualifierSet', ':', INSTANCE_PROP_QUALIFIER_SET),

775 )

776

777# 2.2.58 InstanceHeap

778 INSTANCE_HEAP = HEAP

779

780# 2.2.53 InstanceType

781 class INSTANCE_TYPE(Structure):

782 commonHdr = (

783 ('CurrentClass', ':', CURRENT_CLASS_NO_METHODS),

784 ('EncodingLength', ENCODING_LENGTH),

785 ('InstanceFlags', INSTANCE_FLAGS),

786 ('InstanceClassName', INSTANCE_CLASS_NAME),

787 ('_NdTable_ValueTable', '_-NdTable_ValueTable',

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

789 ('NdTable_ValueTable',':'),

790 ('InstanceQualifierSet', ':', INSTANCE_QUALIFIER_SET),

791 ('InstanceHeap', ':', INSTANCE_HEAP),

792 )

793

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

795 Structure.__init__(self, data, alignment)

796 self.structure = ()

797 if data is not None:

798 # Let's first check the commonHdr

799 self.fromString(data)

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

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

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

803 self.fromString(data)

804 else:

805 self.data = None

806

807 def __processNdTable(self, properties):

808 octetCount = (len(properties) - 1) // 4 + 1 # see [MS-WMIO]: 2.2.26 NdTable

809 packedNdTable = self['NdTable_ValueTable'][:octetCount]

810 unpackedNdTable = [(byte >> shift) & 0b11 for byte in six.iterbytes(packedNdTable) for shift in (0, 2, 4, 6)]

811 for key in properties:

812 ndEntry = unpackedNdTable[properties[key]['order']]

813 properties[key]['null_default'] = bool(ndEntry & 0b01)

814 properties[key]['inherited_default'] = bool(ndEntry & 0b10)

815

816 return octetCount

817

818 @staticmethod

819 def __isNonNullNumber(prop):

820 return prop['type'] & ~Inherited in CIM_NUMBER_TYPES and not prop['null_default']

821

822 def getValues(self, properties):

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

824 valueTableOff = self.__processNdTable(properties)

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

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

827 for key in sorted_props:

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

829 if properties[key]['type'] & CIM_ARRAY_FLAG:

830 unpackStr = HEAPREF[:-2]

831 else:

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

833 dataSize = calcsize(unpackStr)

834 try:

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

836 except:

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

838 itemValue = 0xffffffff

839

840 # if itemValue == 0, default value remains

841 if itemValue != 0 or self.__isNonNullNumber(properties[key]):

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

843 properties[key]['value'] = value

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

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

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

847 valueTable = valueTable[dataSize:]

848 return properties

849

850# 2.2.12 ParentClass

851 PARENT_CLASS = CLASS_AND_METHODS_PART

852

853# 2.2.13 CurrentClass

854 CURRENT_CLASS = CLASS_AND_METHODS_PART

855

856 class CLASS_TYPE(Structure):

857 structure = (

858 ('ParentClass', ':', PARENT_CLASS),

859 ('CurrentClass', ':', CURRENT_CLASS),

860 )

861

862# 2.2.5 ObjectBlock

863 class OBJECT_BLOCK(Structure):

864 commonHdr = (

865 ('ObjectFlags', OBJECT_FLAGS),

866 )

867

868 decoration = (

869 ('Decoration', ':', DECORATION),

870 )

871

872 instanceType = (

873 ('InstanceType', ':', INSTANCE_TYPE),

874 )

875

876 classType = (

877 ('ClassType', ':', CLASS_TYPE),

878 )

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

880 Structure.__init__(self, data, alignment)

881 self.ctParent = None

882 self.ctCurrent = None

883

884 if data is not None:

885 self.structure = ()

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

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

888 self.structure += self.decoration

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

890 # The object is a CIM class.

891 self.structure += self.classType

892 else:

893 self.structure += self.instanceType

894

895 self.fromString(data)

896 else:

897 self.data = None

898

899 def isInstance(self):

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

901 return False

902 return True

903

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

905 qualifiers = pClass.getQualifiers()

906

907 for qualifier in qualifiers:

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

909

910 className = pClass.getClassName()

911

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

913

914 properties = pClass.getProperties()

915 if cInstance is not None:

916 properties = cInstance.getValues(properties)

917

918 for pName in properties:

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

920 qualifiers = properties[pName]['qualifiers']

921 for qName in qualifiers:

922 if qName != 'CIMTYPE':

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

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

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

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

927 print('= IWbemClassObject\n')

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

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

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

931 else:

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

933 else:

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

935 else:

936 print('\n')

937

938 print()

939 methods = pClass.getMethods()

940 for methodName in methods:

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

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

943

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

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

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

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

948 else:

949 returnValue = b''

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

951 # Search the Return Value

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

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

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

955

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

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

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

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

960

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

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

963 if pName != 'ReturnValue':

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

965

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

967

968 print("}")

969

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

971 classDict = OrderedDict()

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

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

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

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

976 if cInstance is not None:

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

978 else:

979 classDict['values'] = None

980

981 return classDict

982

983 def parseObject(self):

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

985 # instance

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

987 currentName = ctCurrent.getClassName()

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

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

990 return

991 else:

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

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

994

995 parentName = ctParent.getClassName()

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

997 self.ctParent = self.parseClass(ctParent)

998

999 currentName = ctCurrent.getClassName()

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

1001 self.ctCurrent = self.parseClass(ctCurrent)

1002

1003 def printInformation(self):

1004 # First off, do we have a class?

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

1006 # instance

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

1008 currentName = ctCurrent.getClassName()

1009 if currentName is not None:

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

1011 return

1012 else:

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

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

1015

1016 parentName = ctParent.getClassName()

1017 if parentName is not None:

1018 self.printClass(ctParent)

1019

1020 currentName = ctCurrent.getClassName()

1021 if currentName is not None:

1022 self.printClass(ctCurrent)

1023

1024# 2.2.70 MethodSignatureBlock

1025 class METHOD_SIGNATURE_BLOCK(Structure):

1026 commonHdr = (

1027 ('EncodingLength', ENCODING_LENGTH),

1028 )

1029 tail = (

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

1031 ('ObjectBlock', ':', OBJECT_BLOCK),

1032 )

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

1034 Structure.__init__(self, data, alignment)

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

1036 self.fromString(data)

1037 if self['EncodingLength'] > 0:

1038 self.structure = ()

1039 self.structure += self.tail

1040 self.fromString(data)

1041 else:

1042 self.data = None

1043

1044# 2.2.1 EncodingUnit

1045 class ENCODING_UNIT(Structure):

1046 structure = (

1047 ('Signature', SIGNATURE),

1048 ('ObjectEncodingLength', OBJECT_ENCODING_LENGTH),

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

1050 ('ObjectBlock', ':', OBJECT_BLOCK),

1051 )

1052

1053################################################################################

1054# CONSTANTS

1055################################################################################

1056# 1.9 Standards Assignments

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

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

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

1060

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

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

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

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

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

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

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

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

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

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

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

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

1073

1074 error_status_t = ULONG

1075

1076# lFlags

1077 WBEM_FLAG_RETURN_WBEM_COMPLETE = 0x00000000

1078 WBEM_FLAG_UPDATE_ONLY = 0x00000001

1079 WBEM_FLAG_CREATE_ONLY = 0x00000002

1080 WBEM_FLAG_RETURN_IMMEDIATELY = 0x00000010

1081 WBEM_FLAG_UPDATE_SAFE_MODE = 0x00000020

1082 WBEM_FLAG_FORWARD_ONLY = 0x00000020

1083 WBEM_FLAG_NO_ERROR_OBJECT = 0x00000040

1084 WBEM_FLAG_UPDATE_FORCE_MODE = 0x00000040

1085 WBEM_FLAG_SEND_STATUS = 0x00000080

1086 WBEM_FLAG_ENSURE_LOCATABLE = 0x00000100

1087 WBEM_FLAG_DIRECT_READ = 0x00000200

1088 WBEM_MASK_RESERVED_FLAGS = 0x0001F000

1089 WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x00020000

1090 WBEM_FLAG_STRONG_VALIDATION = 0x00100000

1091 WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN = 0x00000001

1092

1093 WBEM_INFINITE = 0xffffffff

1094

1095################################################################################

1096# STRUCTURES

1097################################################################################

1098 class UCHAR_ARRAY_CV(NDRUniConformantVaryingArray):

1099 item = 'c'

1100

1101 class PUCHAR_ARRAY_CV(NDRPOINTER):

1102 referent = (

1103 ('Data', UCHAR_ARRAY_CV),

1104 )

1105

1106 class PMInterfacePointer_ARRAY_CV(NDRUniConformantVaryingArray):

1107 item = PMInterfacePointer

1108

1109 REFGUID = PGUID

1110

1111 class ULONG_ARRAY(NDRUniConformantArray):

1112 item = ULONG

1113

1114 class PULONG_ARRAY(NDRPOINTER):

1115 referent = (

1116 ('Data', ULONG_ARRAY),

1117 )

1118

1119# 2.2.5 WBEM_CHANGE_FLAG_TYPE Enumeration

1120 class WBEM_CHANGE_FLAG_TYPE(NDRENUM):

1121 # [v1_enum] type

1122 structure = (

1123 ('Data', '<L'),

1124 )

1125 class enumItems(Enum):

1126 WBEM_FLAG_CREATE_OR_UPDATE = 0x00

1127 WBEM_FLAG_UPDATE_ONLY = 0x01

1128 WBEM_FLAG_CREATE_ONLY = 0x02

1129 WBEM_FLAG_UPDATE_SAFE_MODE = 0x20

1130 WBEM_FLAG_UPDATE_FORCE_MODE = 0x40

1131

1132# 2.2.6 WBEM_GENERIC_FLAG_TYPE Enumeration

1133 class WBEM_GENERIC_FLAG_TYPE(NDRENUM):

1134 # [v1_enum] type

1135 structure = (

1136 ('Data', '<L'),

1137 )

1138 class enumItems(Enum):

1139 WBEM_FLAG_RETURN_WBEM_COMPLETE = 0x00

1140 WBEM_FLAG_RETURN_IMMEDIATELY = 0x10

1141 WBEM_FLAG_FORWARD_ONLY = 0x20

1142 WBEM_FLAG_NO_ERROR_OBJECT = 0x40

1143 WBEM_FLAG_SEND_STATUS = 0x80

1144 WBEM_FLAG_ENSURE_LOCATABLE = 0x100

1145 WBEM_FLAG_DIRECT_READ = 0x200

1146 WBEM_MASK_RESERVED_FLAGS = 0x1F000

1147 WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000

1148 WBEM_FLAG_STRONG_VALIDATION = 0x100000

1149

1150# 2.2.7 WBEM_STATUS_TYPE Enumeration

1151 class WBEM_STATUS_TYPE(NDRENUM):

1152 class enumItems(Enum):

1153 WBEM_STATUS_COMPLETE = 0x00

1154 WBEM_STATUS_REQUIREMENTS = 0x01

1155 WBEM_STATUS_PROGRESS = 0x02

1156

1157# 2.2.8 WBEM_TIMEOUT_TYPE Enumeration

1158 class WBEM_TIMEOUT_TYPE(NDRENUM):

1159 # [v1_enum] type

1160 structure = (

1161 ('Data', '<L'),

1162 )

1163 class enumItems(Enum):

1164 WBEM_NO_WAIT = 0x00000000

1165 WBEM_INFINITE = 0xFFFFFFFF

1166

1167# 2.2.9 WBEM_QUERY_FLAG_TYPE Enumeration

1168 class WBEM_QUERY_FLAG_TYPE(NDRENUM):

1169 # [v1_enum] type

1170 structure = (

1171 ('Data', '<L'),

1172 )

1173 class enumItems(Enum):

1174 WBEM_FLAG_DEEP = 0x00000000

1175 WBEM_FLAG_SHALLOW = 0x00000001

1176 WBEM_FLAG_PROTOTYPE = 0x00000002

1177

1178# 2.2.10 WBEM_BACKUP_RESTORE_FLAGS Enumeration

1179 class WBEM_BACKUP_RESTORE_FLAGS(NDRENUM):

1180 # [v1_enum] type

1181 structure = (

1182 ('Data', '<L'),

1183 )

1184 class enumItems(Enum):

1185 WBEM_FLAG_BACKUP_RESTORE_FORCE_SHUTDOWN = 0x00000001

1186

1187# 2.2.11 WBEMSTATUS Enumeration

1188 class WBEMSTATUS(NDRENUM):

1189 # [v1_enum] type

1190 structure = (

1191 ('Data', '<L'),

1192 )

1193 class enumItems(Enum):

1194 WBEM_S_NO_ERROR = 0x00000000

1195 WBEM_S_FALSE = 0x00000001

1196 WBEM_S_TIMEDOUT = 0x00040004

1197 WBEM_S_NEW_STYLE = 0x000400FF

1198 WBEM_S_PARTIAL_RESULTS = 0x00040010

1199 WBEM_E_FAILED = 0x80041001

1200 WBEM_E_NOT_FOUND = 0x80041002

1201 WBEM_E_ACCESS_DENIED = 0x80041003

1202 WBEM_E_PROVIDER_FAILURE = 0x80041004

1203 WBEM_E_TYPE_MISMATCH = 0x80041005

1204 WBEM_E_OUT_OF_MEMORY = 0x80041006

1205 WBEM_E_INVALID_CONTEXT = 0x80041007

1206 WBEM_E_INVALID_PARAMETER = 0x80041008

1207 WBEM_E_NOT_AVAILABLE = 0x80041009

1208 WBEM_E_CRITICAL_ERROR = 0x8004100a

1209 WBEM_E_NOT_SUPPORTED = 0x8004100c

1210 WBEM_E_PROVIDER_NOT_FOUND = 0x80041011

1211 WBEM_E_INVALID_PROVIDER_REGISTRATION = 0x80041012

1212 WBEM_E_PROVIDER_LOAD_FAILURE = 0x80041013

1213 WBEM_E_INITIALIZATION_FAILURE = 0x80041014

1214 WBEM_E_TRANSPORT_FAILURE = 0x80041015

1215 WBEM_E_INVALID_OPERATION = 0x80041016

1216 WBEM_E_ALREADY_EXISTS = 0x80041019

1217 WBEM_E_UNEXPECTED = 0x8004101d

1218 WBEM_E_INCOMPLETE_CLASS = 0x80041020

1219 WBEM_E_SHUTTING_DOWN = 0x80041033

1220 E_NOTIMPL = 0x80004001

1221 WBEM_E_INVALID_SUPERCLASS = 0x8004100D

1222 WBEM_E_INVALID_NAMESPACE = 0x8004100E

1223 WBEM_E_INVALID_OBJECT = 0x8004100F

1224 WBEM_E_INVALID_CLASS = 0x80041010

1225 WBEM_E_INVALID_QUERY = 0x80041017

1226 WBEM_E_INVALID_QUERY_TYPE = 0x80041018

1227 WBEM_E_PROVIDER_NOT_CAPABLE = 0x80041024

1228 WBEM_E_CLASS_HAS_CHILDREN = 0x80041025

1229 WBEM_E_CLASS_HAS_INSTANCES = 0x80041026

1230 WBEM_E_ILLEGAL_NULL = 0x80041028

1231 WBEM_E_INVALID_CIM_TYPE = 0x8004102D

1232 WBEM_E_INVALID_METHOD = 0x8004102E

1233 WBEM_E_INVALID_METHOD_PARAMETERS = 0x8004102F

1234 WBEM_E_INVALID_PROPERTY = 0x80041031

1235 WBEM_E_CALL_CANCELLED = 0x80041032

1236 WBEM_E_INVALID_OBJECT_PATH = 0x8004103A

1237 WBEM_E_OUT_OF_DISK_SPACE = 0x8004103B

1238 WBEM_E_UNSUPPORTED_PUT_EXTENSION = 0x8004103D

1239 WBEM_E_QUOTA_VIOLATION = 0x8004106c

1240 WBEM_E_SERVER_TOO_BUSY = 0x80041045

1241 WBEM_E_METHOD_NOT_IMPLEMENTED = 0x80041055

1242 WBEM_E_METHOD_DISABLED = 0x80041056

1243 WBEM_E_UNPARSABLE_QUERY = 0x80041058

1244 WBEM_E_NOT_EVENT_CLASS = 0x80041059

1245 WBEM_E_MISSING_GROUP_WITHIN = 0x8004105A

1246 WBEM_E_MISSING_AGGREGATION_LIST = 0x8004105B

1247 WBEM_E_PROPERTY_NOT_AN_OBJECT = 0x8004105c

1248 WBEM_E_AGGREGATING_BY_OBJECT = 0x8004105d

1249 WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING= 0x80041060

1250 WBEM_E_QUEUE_OVERFLOW = 0x80041061

1251 WBEM_E_PRIVILEGE_NOT_HELD = 0x80041062

1252 WBEM_E_INVALID_OPERATOR = 0x80041063

1253 WBEM_E_CANNOT_BE_ABSTRACT = 0x80041065

1254 WBEM_E_AMENDED_OBJECT = 0x80041066

1255 WBEM_E_VETO_PUT = 0x8004107A

1256 WBEM_E_PROVIDER_SUSPENDED = 0x80041081

1257 WBEM_E_ENCRYPTED_CONNECTION_REQUIRED = 0x80041087

1258 WBEM_E_PROVIDER_TIMED_OUT = 0x80041088

1259 WBEM_E_NO_KEY = 0x80041089

1260 WBEM_E_PROVIDER_DISABLED = 0x8004108a

1261 WBEM_E_REGISTRATION_TOO_BROAD = 0x80042001

1262 WBEM_E_REGISTRATION_TOO_PRECISE = 0x80042002

1263

1264# 2.2.12 WBEM_CONNECT_OPTIONS Enumeration

1265 class WBEM_CONNECT_OPTIONS(NDRENUM):

1266 # [v1_enum] type

1267 structure = (

1268 ('Data', '<L'),

1269 )

1270 class enumItems(Enum):

1271 WBEM_FLAG_CONNECT_REPOSITORY_ONLY = 0x40

1272 WBEM_FLAG_CONNECT_PROVIDERS = 0x100

1273

1274# 2.2.14 ObjectArray Structure

1275 class ObjectArray(Structure):

1276 structure = (

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

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

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

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

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

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

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

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

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

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

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

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

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

1290 ('wbemObjects', ':'),

1291 )

1292

1293# 2.2.14.1 WBEM_DATAPACKET_OBJECT Structure

1294 class WBEM_DATAPACKET_OBJECT(Structure):

1295 structure = (

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

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

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

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

1300 ('Object', ':'),

1301 )

1302

1303# 2.2.14.2 WBEMOBJECT_CLASS Structure

1304 class WBEMOBJECT_CLASS(Structure):

1305 structure = (

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

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

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

1309 ('ObjectData', ':'),

1310 )

1311

1312# 2.2.14.3 WBEMOBJECT_INSTANCE Structure

1313 class WBEMOBJECT_INSTANCE(Structure):

1314 structure = (

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

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

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

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

1319 ('ObjectData', ':'),

1320 )

1321

1322# 2.2.14.4 WBEMOBJECT_INSTANCE_NOCLASS Structure

1323 class WBEMOBJECT_INSTANCE_NOCLASS(Structure):

1324 structure = (

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

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

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

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

1329 ('ObjectData', ':'),

1330 )

1331

1332# 2.2.15 WBEM_REFRESHED_OBJECT Structure

1333 class WBEM_REFRESHED_OBJECT(NDRSTRUCT):

1334 structure = (

1335 ('m_lRequestId', LONG),

1336 ('m_lBlobType', LONG),

1337 ('m_lBlobLength', LONG),

1338 ('m_pBlob', BYTE_ARRAY),

1339 )

1340

1341 class WBEM_REFRESHED_OBJECT_ARRAY(NDRUniConformantArray):

1342 item = WBEM_REFRESHED_OBJECT

1343

1344 class PWBEM_REFRESHED_OBJECT_ARRAY(NDRPOINTER):

1345 referent = (

1346 ('Data', WBEM_REFRESHED_OBJECT_ARRAY),

1347 )

1348

1349# 2.2.16 WBEM_INSTANCE_BLOB Enumeration

1350 class WBEM_INSTANCE_BLOB(Structure):

1351 structure = (

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

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

1354 ('Objects', ':'),

1355 )

1356

1357# 2.2.17 WBEM_INSTANCE_BLOB_TYPE Enumeration

1358 class WBEM_INSTANCE_BLOB_TYPE(NDRENUM):

1359 # [v1_enum] type

1360 structure = (

1361 ('Data', '<L'),

1362 )

1363 class enumItems(Enum):

1364 WBEM_FLAG_CONNECT_REPOSITORY_ONLY = 0x40

1365 WBEM_FLAG_CONNECT_PROVIDERS = 0x100

1366

1367# 2.2.26 _WBEM_REFRESH_INFO_NON_HIPERF Structure

1368 class _WBEM_REFRESH_INFO_NON_HIPERF(NDRSTRUCT):

1369 structure = (

1370 ('m_wszNamespace', LPWSTR),

1371 ('m_pTemplate', PMInterfacePointer),

1372 )

1373

1374# 2.2.27 _WBEM_REFRESH_INFO_REMOTE Structure

1375 class _WBEM_REFRESH_INFO_REMOTE(NDRSTRUCT):

1376 structure = (

1377 ('m_pRefresher', PMInterfacePointer),

1378 ('m_pTemplate', PMInterfacePointer),

1379 ('m_Guid', GUID),

1380 )

1381

1382# 2.2.25 WBEM_REFRESH_TYPE Enumeration

1383 class WBEM_REFRESH_TYPE(NDRENUM):

1384 class enumItems(Enum):

1385 WBEM_REFRESH_TYPE_INVALID = 0

1386 WBEM_REFRESH_TYPE_REMOTE = 3

1387 WBEM_REFRESH_TYPE_NON_HIPERF = 6

1388

1389# 2.2.28 _WBEM_REFRESH_INFO_UNION Union

1390 class _WBEM_REFRESH_INFO_UNION(NDRUNION):

1391 commonHdr = (

1392 ('tag', LONG),

1393 )

1394 union = {

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

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

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

1398 }

1399

1400# 2.2.20 _WBEM_REFRESH_INFO Structure

1401 class _WBEM_REFRESH_INFO(NDRSTRUCT):

1402 structure = (

1403 ('m_lType', LONG),

1404 ('m_Info', _WBEM_REFRESH_INFO_UNION),

1405 ('m_lCancelId', LONG),

1406 )

1407

1408# 2.2.21 _WBEM_REFRESHER_ID Structure

1409 class _WBEM_REFRESHER_ID(NDRSTRUCT):

1410 structure = (

1411 ('m_szMachineName', LPCSTR),

1412 ('m_dwProcessId', DWORD),

1413 ('m_guidRefresherId', GUID),

1414 )

1415

1416# 2.2.22 _WBEM_RECONNECT_INFO Structure

1417 class _WBEM_RECONNECT_INFO(NDRSTRUCT):

1418 structure = (

1419 ('m_lType', LPCSTR),

1420 ('m_pwcsPath', LPWSTR),

1421 )

1422

1423 class _WBEM_RECONNECT_INFO_ARRAY(NDRUniConformantArray):

1424 item = _WBEM_RECONNECT_INFO

1425

1426# 2.2.23 _WBEM_RECONNECT_RESULTS Structure

1427 class _WBEM_RECONNECT_RESULTS(NDRSTRUCT):

1428 structure = (

1429 ('m_lId', LONG),

1430 ('m_hr', HRESULT),

1431 )

1432

1433 class _WBEM_RECONNECT_RESULTS_ARRAY(NDRUniConformantArray):

1434 item = _WBEM_RECONNECT_INFO

1435

1436

1437################################################################################

1438# RPC CALLS

1439################################################################################

1440# 3.1.4.1 IWbemLevel1Login Interface

1441# 3.1.4.1.1 IWbemLevel1Login::EstablishPosition (Opnum 3)

1442 class IWbemLevel1Login_EstablishPosition(DCOMCALL):

1443 opnum = 3

1444 structure = (

1445 ('reserved1', LPWSTR),

1446 ('reserved2', DWORD),

1447 )

1448

1449 class IWbemLevel1Login_EstablishPositionResponse(DCOMANSWER):

1450 structure = (

1451 ('LocaleVersion', DWORD),

1452 ('ErrorCode', error_status_t),

1453 )

1454

1455# 3.1.4.1.2 IWbemLevel1Login::RequestChallenge (Opnum 4)

1456 class IWbemLevel1Login_RequestChallenge(DCOMCALL):

1457 opnum = 4

1458 structure = (

1459 ('reserved1', LPWSTR),

1460 ('reserved2', LPWSTR),

1461 )

1462

1463 class IWbemLevel1Login_RequestChallengeResponse(DCOMANSWER):

1464 structure = (

1465 ('reserved3', UCHAR_ARRAY_CV),

1466 ('ErrorCode', error_status_t),

1467 )

1468

1469# 3.1.4.1.3 IWbemLevel1Login::WBEMLogin (Opnum 5)

1470 class IWbemLevel1Login_WBEMLogin(DCOMCALL):

1471 opnum = 5

1472 structure = (

1473 ('reserved1', LPWSTR),

1474 ('reserved2', PUCHAR_ARRAY_CV),

1475 ('reserved3', LONG),

1476 ('reserved4', PMInterfacePointer),

1477 )

1478

1479 class IWbemLevel1Login_WBEMLoginResponse(DCOMANSWER):

1480 structure = (

1481 ('reserved5', UCHAR_ARRAY_CV),

1482 ('ErrorCode', error_status_t),

1483 )

1484

1485# 3.1.4.1.4 IWbemLevel1Login::NTLMLogin (Opnum 6)

1486 class IWbemLevel1Login_NTLMLogin(DCOMCALL):

1487 opnum = 6

1488 structure = (

1489 ('wszNetworkResource', LPWSTR),

1490 ('wszPreferredLocale', LPWSTR),

1491 ('lFlags', LONG),

1492 ('pCtx', PMInterfacePointer),

1493 )

1494

1495 class IWbemLevel1Login_NTLMLoginResponse(DCOMANSWER):

1496 structure = (

1497 ('ppNamespace', PMInterfacePointer),

1498 ('ErrorCode', error_status_t),

1499 )

1500

1501# 3.1.4.2 IWbemObjectSink Interface Server Details

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

1503 class IWbemObjectSink_Indicate(DCOMCALL):

1504 opnum = 3

1505 structure = (

1506 ('lObjectCount', LONG),

1507 ('apObjArray', PMInterfacePointer_ARRAY),

1508 )

1509

1510 class IWbemObjectSink_IndicateResponse(DCOMANSWER):

1511 structure = (

1512 ('ErrorCode', error_status_t),

1513 )

1514

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

1516 class IWbemObjectSink_SetStatus(DCOMCALL):

1517 opnum = 4

1518 structure = (

1519 ('lFlags', LONG),

1520 ('hResult', HRESULT),

1521 ('strParam', BSTR),

1522 ('pObjParam', PMInterfacePointer),

1523 )

1524

1525 class IWbemObjectSink_SetStatusResponse(DCOMANSWER):

1526 structure = (

1527 ('ErrorCode', error_status_t),

1528 )

1529

1530# 3.1.4.3 IWbemServices Interface

1531# 3.1.4.3.1 IWbemServices::OpenNamespace (Opnum 3)

1532 class IWbemServices_OpenNamespace(DCOMCALL):

1533 opnum = 3

1534 structure = (

1535 ('strNamespace', BSTR),

1536 ('lFlags', LONG),

1537 ('pCtx', PMInterfacePointer),

1538 ('ppWorkingNamespace', PMInterfacePointer),

1539 ('ppResult', PMInterfacePointer),

1540 )

1541

1542 class IWbemServices_OpenNamespaceResponse(DCOMANSWER):

1543 structure = (

1544 ('ppWorkingNamespace', PPMInterfacePointer),

1545 ('ppResult', PPMInterfacePointer),

1546 ('ErrorCode', error_status_t),

1547 )

1548

1549# 3.1.4.3.2 IWbemServices::CancelAsyncCall (Opnum 4)

1550 class IWbemServices_CancelAsyncCall(DCOMCALL):

1551 opnum = 4

1552 structure = (

1553 ('IWbemObjectSink', PMInterfacePointer),

1554 )

1555

1556 class IWbemServices_CancelAsyncCallResponse(DCOMANSWER):

1557 structure = (

1558 ('ErrorCode', error_status_t),

1559 )

1560

1561# 3.1.4.3.3 IWbemServices::QueryObjectSink (Opnum 5)

1562 class IWbemServices_QueryObjectSink(DCOMCALL):

1563 opnum = 5

1564 structure = (

1565 ('lFlags', LONG),

1566 )

1567

1568 class IWbemServices_QueryObjectSinkResponse(DCOMANSWER):

1569 structure = (

1570 ('ppResponseHandler', PMInterfacePointer),

1571 ('ErrorCode', error_status_t),

1572 )

1573

1574# 3.1.4.3.4 IWbemServices::GetObject (Opnum 6)

1575 class IWbemServices_GetObject(DCOMCALL):

1576 opnum = 6

1577 structure = (

1578 ('strObjectPath', BSTR),

1579 ('lFlags', LONG),

1580 ('pCtx', PMInterfacePointer),

1581 ('ppObject', PMInterfacePointer),

1582 ('ppCallResult', PMInterfacePointer),

1583 )

1584

1585 class IWbemServices_GetObjectResponse(DCOMANSWER):

1586 structure = (

1587 ('ppObject', PPMInterfacePointer),

1588 ('ppCallResult', PPMInterfacePointer),

1589 ('ErrorCode', error_status_t),

1590 )

1591

1592# 3.1.4.3.5 IWbemServices::GetObjectAsync (Opnum 7)

1593 class IWbemServices_GetObjectAsync(DCOMCALL):

1594 opnum = 7

1595 structure = (

1596 ('strObjectPath', BSTR),

1597 ('lFlags', LONG),

1598 ('pCtx', PMInterfacePointer),

1599 ('pResponseHandler', PMInterfacePointer),

1600 )

1601

1602 class IWbemServices_GetObjectAsyncResponse(DCOMANSWER):

1603 structure = (

1604 ('ErrorCode', error_status_t),

1605 )

1606

1607# 3.1.4.3.6 IWbemServices::PutClass (Opnum 8)

1608 class IWbemServices_PutClass(DCOMCALL):

1609 opnum = 8

1610 structure = (

1611 ('pObject', PMInterfacePointer),

1612 ('lFlags', LONG),

1613 ('pCtx', PMInterfacePointer),

1614 ('pResponseHandler', PMInterfacePointer),

1615 ('ppCallResult', PMInterfacePointer),

1616 )

1617

1618 class IWbemServices_PutClassResponse(DCOMANSWER):

1619 structure = (

1620 ('ppCallResult', PPMInterfacePointer),

1621 ('ErrorCode', error_status_t),

1622 )

1623

1624# 3.1.4.3.7 IWbemServices::PutClassAsync (Opnum 9)

1625 class IWbemServices_PutClassAsync(DCOMCALL):

1626 opnum = 9

1627 structure = (

1628 ('pObject', PMInterfacePointer),

1629 ('lFlags', LONG),

1630 ('pCtx', PMInterfacePointer),

1631 ('pResponseHandler', PMInterfacePointer),

1632 )

1633

1634 class IWbemServices_PutClassAsyncResponse(DCOMANSWER):

1635 structure = (

1636 ('ErrorCode', error_status_t),

1637 )

1638

1639# 3.1.4.3.8 IWbemServices::DeleteClass (Opnum 10)

1640 class IWbemServices_DeleteClass(DCOMCALL):

1641 opnum = 10

1642 structure = (

1643 ('strClass', BSTR),

1644 ('lFlags', LONG),

1645 ('pCtx', PMInterfacePointer),

1646 ('ppCallResult', PMInterfacePointer),

1647 )

1648

1649 class IWbemServices_DeleteClassResponse(DCOMANSWER):

1650 structure = (

1651 ('ppCallResult', PPMInterfacePointer),

1652 ('ErrorCode', error_status_t),

1653 )

1654

1655# 3.1.4.3.9 IWbemServices::DeleteClassAsync (Opnum 11)

1656 class IWbemServices_DeleteClassAsync(DCOMCALL):

1657 opnum = 11

1658 structure = (

1659 ('strClass', BSTR),

1660 ('lFlags', LONG),

1661 ('pCtx', PMInterfacePointer),

1662 ('pResponseHandler', PMInterfacePointer),

1663 )

1664

1665 class IWbemServices_DeleteClassAsyncResponse(DCOMANSWER):

1666 structure = (

1667 ('ErrorCode', error_status_t),

1668 )

1669

1670# 3.1.4.3.10 IWbemServices::CreateClassEnum (Opnum 12)

1671 class IWbemServices_CreateClassEnum(DCOMCALL):

1672 opnum = 12

1673 structure = (

1674 ('strSuperClass', BSTR),

1675 ('lFlags', LONG),

1676 ('pCtx', PMInterfacePointer),

1677 )

1678

1679 class IWbemServices_CreateClassEnumResponse(DCOMANSWER):

1680 structure = (

1681 ('ppEnum', PMInterfacePointer),

1682 ('ErrorCode', error_status_t),

1683 )

1684

1685# 3.1.4.3.11 IWbemServices::CreateClassEnumAsync (Opnum 13)

1686 class IWbemServices_CreateClassEnumAsync(DCOMCALL):

1687 opnum = 13

1688 structure = (

1689 ('strSuperClass', BSTR),

1690 ('lFlags', LONG),

1691 ('pCtx', PMInterfacePointer),

1692 ('pResponseHandler', PMInterfacePointer),

1693 )

1694

1695 class IWbemServices_CreateClassEnumAsyncResponse(DCOMANSWER):

1696 structure = (

1697 ('ErrorCode', error_status_t),

1698 )

1699

1700# 3.1.4.3.12 IWbemServices::PutInstance (Opnum 14)

1701 class IWbemServices_PutInstance(DCOMCALL):

1702 opnum = 14

1703 structure = (

1704 ('pInst', PMInterfacePointer),

1705 ('lFlags', LONG),

1706 ('pCtx', PMInterfacePointer),

1707 ('ppCallResult', PMInterfacePointer),

1708 )

1709

1710 class IWbemServices_PutInstanceResponse(DCOMANSWER):

1711 structure = (

1712 ('ppCallResult', PPMInterfacePointer),

1713 ('ErrorCode', error_status_t),

1714 )

1715

1716# 3.1.4.3.13 IWbemServices::PutInstanceAsync (Opnum 15)

1717 class IWbemServices_PutInstanceAsync(DCOMCALL):

1718 opnum = 15

1719 structure = (

1720 ('pInst', PMInterfacePointer),

1721 ('lFlags', LONG),

1722 ('pCtx', PMInterfacePointer),

1723 ('pResponseHandler', PMInterfacePointer),

1724 )

1725

1726 class IWbemServices_PutInstanceAsyncResponse(DCOMANSWER):

1727 structure = (

1728 ('ErrorCode', error_status_t),

1729 )

1730

1731# 3.1.4.3.14 IWbemServices::DeleteInstance (Opnum 16)

1732 class IWbemServices_DeleteInstance(DCOMCALL):

1733 opnum = 16

1734 structure = (

1735 ('strObjectPath', BSTR),

1736 ('lFlags', LONG),

1737 ('pCtx', PMInterfacePointer),

1738 ('ppCallResult', PMInterfacePointer),

1739 )

1740

1741 class IWbemServices_DeleteInstanceResponse(DCOMANSWER):

1742 structure = (

1743 ('ppCallResult', PPMInterfacePointer),

1744 ('ErrorCode', error_status_t),

1745 )

1746

1747# 3.1.4.3.15 IWbemServices::DeleteInstanceAsync (Opnum 17)

1748 class IWbemServices_DeleteInstanceAsync(DCOMCALL):

1749 opnum = 17

1750 structure = (

1751 ('strObjectPath', BSTR),

1752 ('lFlags', LONG),

1753 ('pCtx', PMInterfacePointer),

1754 ('pResponseHandler', PMInterfacePointer),

1755 )

1756

1757 class IWbemServices_DeleteInstanceAsyncResponse(DCOMANSWER):

1758 structure = (

1759 ('ErrorCode', error_status_t),

1760 )

1761

1762# 3.1.4.3.16 IWbemServices::CreateInstanceEnum (Opnum 18)

1763 class IWbemServices_CreateInstanceEnum(DCOMCALL):

1764 opnum = 18

1765 structure = (

1766 ('strSuperClass', BSTR),

1767 ('lFlags', LONG),

1768 ('pCtx', PMInterfacePointer),

1769 )

1770

1771 class IWbemServices_CreateInstanceEnumResponse(DCOMANSWER):

1772 structure = (

1773 ('ppEnum', PMInterfacePointer),

1774 ('ErrorCode', error_status_t),

1775 )

1776

1777# 3.1.4.3.17 IWbemServices::CreateInstanceEnumAsync (Opnum 19)

1778 class IWbemServices_CreateInstanceEnumAsync(DCOMCALL):

1779 opnum = 19

1780 structure = (

1781 ('strSuperClass', BSTR),

1782 ('lFlags', LONG),

1783 ('pCtx', PMInterfacePointer),

1784 ('pResponseHandler', PMInterfacePointer),

1785 )

1786

1787 class IWbemServices_CreateInstanceEnumAsyncResponse(DCOMANSWER):

1788 structure = (

1789 ('ErrorCode', error_status_t),

1790 )

1791

1792# 3.1.4.3.18 IWbemServices::ExecQuery (Opnum 20)

1793 class IWbemServices_ExecQuery(DCOMCALL):

1794 opnum = 20

1795 structure = (

1796 ('strQueryLanguage', BSTR),

1797 ('strQuery', BSTR),

1798 ('lFlags', LONG),

1799 ('pCtx', PMInterfacePointer),

1800 )

1801

1802 class IWbemServices_ExecQueryResponse(DCOMANSWER):

1803 structure = (

1804 ('ppEnum', PMInterfacePointer),

1805 ('ErrorCode', error_status_t),

1806 )

1807

1808# 3.1.4.3.19 IWbemServices::ExecQueryAsync (Opnum 21)

1809 class IWbemServices_ExecQueryAsync(DCOMCALL):

1810 opnum = 21

1811 structure = (

1812 ('strQueryLanguage', BSTR),

1813 ('strQuery', BSTR),

1814 ('lFlags', LONG),

1815 ('pCtx', PMInterfacePointer),

1816 ('pResponseHandler', PMInterfacePointer),

1817 )

1818

1819 class IWbemServices_ExecQueryAsyncResponse(DCOMANSWER):

1820 structure = (

1821 ('ErrorCode', error_status_t),

1822 )

1823

1824# 3.1.4.3.20 IWbemServices::ExecNotificationQuery (Opnum 22)

1825 class IWbemServices_ExecNotificationQuery(DCOMCALL):

1826 opnum = 22

1827 structure = (

1828 ('strQueryLanguage', BSTR),

1829 ('strQuery', BSTR),

1830 ('lFlags', LONG),

1831 ('pCtx', PMInterfacePointer),

1832 )

1833

1834 class IWbemServices_ExecNotificationQueryResponse(DCOMANSWER):

1835 structure = (

1836 ('ppEnum', PMInterfacePointer),

1837 ('ErrorCode', error_status_t),

1838 )

1839

1840# 3.1.4.3.21 IWbemServices::ExecNotificationQueryAsync (Opnum 23)

1841 class IWbemServices_ExecNotificationQueryAsync(DCOMCALL):

1842 opnum = 23

1843 structure = (

1844 ('strQueryLanguage', BSTR),

1845 ('strQuery', BSTR),

1846 ('lFlags', LONG),

1847 ('pCtx', PMInterfacePointer),

1848 ('pResponseHandler', PMInterfacePointer),

1849 )

1850

1851 class IWbemServices_ExecNotificationQueryAsyncResponse(DCOMANSWER):

1852 structure = (

1853 ('ErrorCode', error_status_t),

1854 )

1855

1856# 3.1.4.3.22 IWbemServices::ExecMethod (Opnum 24)

1857 class IWbemServices_ExecMethod(DCOMCALL):

1858 opnum = 24

1859 structure = (

1860 ('strObjectPath', BSTR),

1861 ('strMethodName', BSTR),

1862 ('lFlags', LONG),

1863 ('pCtx', PMInterfacePointer),

1864 ('pInParams', PMInterfacePointer),

1865 ('ppOutParams', PPMInterfacePointer),

1866 ('ppCallResult', PPMInterfacePointer),

1867 )

1868

1869 class IWbemServices_ExecMethodResponse(DCOMANSWER):

1870 structure = (

1871 ('ppOutParams', PPMInterfacePointer),

1872 ('ppCallResult', PPMInterfacePointer),

1873 ('ErrorCode', error_status_t),

1874 )

1875

1876# 3.1.4.3.23 IWbemServices::ExecMethodAsync (Opnum 25)

1877 class IWbemServices_ExecMethodAsync(DCOMCALL):

1878 opnum = 25

1879 structure = (

1880 ('strObjectPath', BSTR),

1881 ('strMethodName', BSTR),

1882 ('lFlags', LONG),

1883 ('pCtx', PMInterfacePointer),

1884 ('pInParams', PMInterfacePointer),

1885 ('pResponseHandler', PMInterfacePointer),

1886 )

1887

1888 class IWbemServices_ExecMethodAsyncResponse(DCOMANSWER):

1889 structure = (

1890 ('ErrorCode', error_status_t),

1891 )

1892

1893# 3.1.4.4 IEnumWbemClassObject Interface

1894# 3.1.4.4.1 IEnumWbemClassObject::Reset (Opnum 3)

1895 class IEnumWbemClassObject_Reset(DCOMCALL):

1896 opnum = 3

1897 structure = (

1898 )

1899

1900 class IEnumWbemClassObject_ResetResponse(DCOMANSWER):

1901 structure = (

1902 ('ErrorCode', error_status_t),

1903 )

1904

1905# 3.1.4.4.2 IEnumWbemClassObject::Next (Opnum 4)

1906 class IEnumWbemClassObject_Next(DCOMCALL):

1907 opnum = 4

1908 structure = (

1909 ('lTimeout', ULONG),

1910 ('uCount', ULONG),

1911 )

1912

1913 class IEnumWbemClassObject_NextResponse(DCOMANSWER):

1914 structure = (

1915 ('apObjects', PMInterfacePointer_ARRAY_CV),

1916 ('puReturned', ULONG),

1917 ('ErrorCode', error_status_t),

1918 )

1919

1920# 3.1.4.4.3 IEnumWbemClassObject::NextAsync (Opnum 5)

1921 class IEnumWbemClassObject_NextAsync(DCOMCALL):

1922 opnum = 5

1923 structure = (

1924 ('lTimeout', LONG),

1925 ('pSink', PMInterfacePointer),

1926 )

1927

1928 class IEnumWbemClassObject_NextAsyncResponse(DCOMANSWER):

1929 structure = (

1930 ('ErrorCode', error_status_t),

1931 )

1932

1933# 3.1.4.4.4 IEnumWbemClassObject::Clone (Opnum 6)

1934 class IEnumWbemClassObject_Clone(DCOMCALL):

1935 opnum = 6

1936 structure = (

1937 )

1938

1939 class IEnumWbemClassObject_CloneResponse(DCOMANSWER):

1940 structure = (

1941 ('ppEnum', PMInterfacePointer),

1942 ('ErrorCode', error_status_t),

1943 )

1944

1945# 3.1.4.4.5 IEnumWbemClassObject::Skip (Opnum 7)

1946 class IEnumWbemClassObject_Skip(DCOMCALL):

1947 opnum = 7

1948 structure = (

1949 ('lTimeout', LONG),

1950 ('uCount', ULONG),

1951 )

1952

1953 class IEnumWbemClassObject_SkipResponse(DCOMANSWER):

1954 structure = (

1955 ('ErrorCode', error_status_t),

1956 )

1957

1958# 3.1.4.5 IWbemCallResult Interface

1959# 3.1.4.5.1 IWbemCallResult::GetResultObject (Opnum 3)

1960 class IWbemCallResult_GetResultObject(DCOMCALL):

1961 opnum = 3

1962 structure = (

1963 ('lTimeout', LONG),

1964 )

1965

1966 class IWbemCallResult_GetResultObjectResponse(DCOMANSWER):

1967 structure = (

1968 ('ppResultObject', PMInterfacePointer),

1969 ('ErrorCode', error_status_t),

1970 )

1971

1972# 3.1.4.5.2 IWbemCallResult::GetResultString (Opnum 4)

1973 class IWbemCallResult_GetResultString(DCOMCALL):

1974 opnum = 4

1975 structure = (

1976 ('lTimeout', LONG),

1977 )

1978

1979 class IWbemCallResult_GetResultStringResponse(DCOMANSWER):

1980 structure = (

1981 ('pstrResultString', BSTR),

1982 ('ErrorCode', error_status_t),

1983 )

1984

1985# 3.1.4.5.3 IWbemCallResult::GetResultServices (Opnum 5)

1986 class IWbemCallResult_GetResultServices(DCOMCALL):

1987 opnum = 5

1988 structure = (

1989 ('lTimeout', LONG),

1990 )

1991

1992 class IWbemCallResult_GetResultServicesResponse(DCOMANSWER):

1993 structure = (

1994 ('ppServices', PMInterfacePointer),

1995 ('ErrorCode', error_status_t),

1996 )

1997

1998# 3.1.4.5.4 IWbemCallResult::GetCallStatus (Opnum 6)

1999 class IWbemCallResult_GetCallStatus(DCOMCALL):

2000 opnum = 6

2001 structure = (

2002 ('lTimeout', LONG),

2003 )

2004

2005 class IWbemCallResult_GetCallStatusResponse(DCOMANSWER):

2006 structure = (

2007 ('plStatus', LONG),

2008 ('ErrorCode', error_status_t),

2009 )

2010

2011# 3.1.4.6 IWbemFetchSmartEnum Interface

2012# 3.1.4.6.1 IWbemFetchSmartEnum::GetSmartEnum (Opnum 3)

2013 class IWbemFetchSmartEnum_GetSmartEnum(DCOMCALL):

2014 opnum = 3

2015 structure = (

2016 )

2017

2018 class IWbemFetchSmartEnum_GetSmartEnumResponse(DCOMANSWER):

2019 structure = (

2020 ('ppSmartEnum', PMInterfacePointer),

2021 ('ErrorCode', error_status_t),

2022 )

2023

2024# 3.1.4.7 IWbemWCOSmartEnum Interface

2025# 3.1.4.7.1 IWbemWCOSmartEnum::Next (Opnum 3)

2026 class IWbemWCOSmartEnum_Next(DCOMCALL):

2027 opnum = 3

2028 structure = (

2029 ('proxyGUID', REFGUID),

2030 ('lTimeout', LONG),

2031 ('uCount', ULONG),

2032 )

2033

2034 class IWbemWCOSmartEnum_NextResponse(DCOMANSWER):

2035 structure = (

2036 ('puReturned', ULONG),

2037 ('pdwBuffSize', ULONG),

2038 ('pBuffer', BYTE_ARRAY),

2039 ('ErrorCode', error_status_t),

2040 )

2041

2042# 3.1.4.8 IWbemLoginClientID Interface

2043# 3.1.4.8.1 IWbemLoginClientID::SetClientInfo (Opnum 3)

2044 class IWbemLoginClientID_SetClientInfo(DCOMCALL):

2045 opnum = 3

2046 structure = (

2047 ('wszClientMachine', LPWSTR),

2048 ('lClientProcId', LONG),

2049 ('lReserved', LONG),

2050 )

2051

2052 class IWbemLoginClientID_SetClientInfoResponse(DCOMANSWER):

2053 structure = (

2054 ('ErrorCode', error_status_t),

2055 )

2056

2057# 3.1.4.9 IWbemLoginHelper Interface

2058# 3.1.4.9.1 IWbemLoginHelper::SetEvent (Opnum 3)

2059 class IWbemLoginHelper_SetEvent(DCOMCALL):

2060 opnum = 3

2061 structure = (

2062 ('sEventToSet', LPCSTR),

2063 )

2064

2065 class IWbemLoginHelper_SetEventResponse(DCOMANSWER):

2066 structure = (

2067 ('ErrorCode', error_status_t),

2068 )

2069

2070#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

2071# 3.1.4.10 IWbemBackupRestore Interface

2072# 3.1.4.10.1 IWbemBackupRestore::Backup (Opnum 3)

2073 class IWbemBackupRestore_Backup(DCOMCALL):

2074 opnum = 3

2075 structure = (

2076 ('strBackupToFile', LPWSTR),

2077 ('lFlags', LONG),

2078 )

2079

2080 class IWbemBackupRestore_BackupResponse(DCOMANSWER):

2081 structure = (

2082 ('ErrorCode', error_status_t),

2083 )

2084

2085# 3.1.4.10.2 IWbemBackupRestore::Restore (Opnum 4)

2086 class IWbemBackupRestore_Restore(DCOMCALL):

2087 opnum = 4

2088 structure = (

2089 ('strRestoreFromFile', LPWSTR),

2090 ('lFlags', LONG),

2091 )

2092

2093 class IWbemBackupRestore_RestoreResponse(DCOMANSWER):

2094 structure = (

2095 ('ErrorCode', error_status_t),

2096 )

2097

2098# 3.1.4.11 IWbemBackupRestoreEx Interface

2099# 3.1.4.11.1 IWbemBackupRestoreEx::Pause (Opnum 5)

2100 class IWbemBackupRestoreEx_Pause(DCOMCALL):

2101 opnum = 5

2102 structure = (

2103 )

2104

2105 class IWbemBackupRestoreEx_PauseResponse(DCOMANSWER):

2106 structure = (

2107 ('ErrorCode', error_status_t),

2108 )

2109

2110# 3.1.4.11.2 IWbemBackupRestoreEx::Resume (Opnum 6)

2111 class IWbemBackupRestoreEx_Resume(DCOMCALL):

2112 opnum = 6

2113 structure = (

2114 )

2115

2116 class IWbemBackupRestoreEx_ResumeResponse(DCOMANSWER):

2117 structure = (

2118 ('ErrorCode', error_status_t),

2119 )

2120

2121# 3.1.4.12 IWbemRefreshingServices Interface

2122# 3.1.4.12.1 IWbemRefreshingServices::AddObjectToRefresher (Opnum 3)

2123 class IWbemRefreshingServices_AddObjectToRefresher(DCOMCALL):

2124 opnum = 3

2125 structure = (

2126 ('pRefresherId', _WBEM_REFRESHER_ID),

2127 ('wszPath', LPWSTR),

2128 ('lFlags', LONG),

2129 ('pContext', PMInterfacePointer),

2130 ('dwClientRefrVersion', DWORD),

2131 )

2132

2133 class IWbemRefreshingServices_AddObjectToRefresherResponse(DCOMANSWER):

2134 structure = (

2135 ('pInfo', _WBEM_REFRESH_INFO),

2136 ('pdwSvrRefrVersion', DWORD),

2137 ('ErrorCode', error_status_t),

2138 )

2139

2140# 3.1.4.12.2 IWbemRefreshingServices::AddObjectToRefresherByTemplate (Opnum 4)

2141 class IWbemRefreshingServices_AddObjectToRefresherByTemplate(DCOMCALL):

2142 opnum = 4

2143 structure = (

2144 ('pRefresherId', _WBEM_REFRESHER_ID),

2145 ('pTemplate', PMInterfacePointer),

2146 ('lFlags', LONG),

2147 ('pContext', PMInterfacePointer),

2148 ('dwClientRefrVersion', DWORD),

2149 )

2150

2151 class IWbemRefreshingServices_AddObjectToRefresherByTemplateResponse(DCOMANSWER):

2152 structure = (

2153 ('pInfo', _WBEM_REFRESH_INFO),

2154 ('pdwSvrRefrVersion', DWORD),

2155 ('ErrorCode', error_status_t),

2156 )

2157

2158# 3.1.4.12.3 IWbemRefreshingServices::AddEnumToRefresher (Opnum 5)

2159 class IWbemRefreshingServices_AddEnumToRefresher(DCOMCALL):

2160 opnum = 5

2161 structure = (

2162 ('pRefresherId', _WBEM_REFRESHER_ID),

2163 ('wszClass', LPWSTR),

2164 ('lFlags', LONG),

2165 ('pContext', PMInterfacePointer),

2166 ('dwClientRefrVersion', DWORD),

2167 )

2168

2169 class IWbemRefreshingServices_AddEnumToRefresherResponse(DCOMANSWER):

2170 structure = (

2171 ('pInfo', _WBEM_REFRESH_INFO),

2172 ('pdwSvrRefrVersion', DWORD),

2173 ('ErrorCode', error_status_t),

2174 )

2175

2176# 3.1.4.12.4 IWbemRefreshingServices::RemoveObjectFromRefresher (Opnum 6)

2177 class IWbemRefreshingServices_RemoveObjectFromRefresher(DCOMCALL):

2178 opnum = 6

2179 structure = (

2180 ('pRefresherId', _WBEM_REFRESHER_ID),

2181 ('lId', LONG),

2182 ('lFlags', LONG),

2183 ('dwClientRefrVersion', DWORD),

2184 )

2185

2186 class IWbemRefreshingServices_RemoveObjectFromRefresherResponse(DCOMANSWER):

2187 structure = (

2188 ('pdwSvrRefrVersion', DWORD),

2189 ('ErrorCode', error_status_t),

2190 )

2191

2192# 3.1.4.12.5 IWbemRefreshingServices::GetRemoteRefresher (Opnum 7)

2193 class IWbemRefreshingServices_GetRemoteRefresher(DCOMCALL):

2194 opnum = 7

2195 structure = (

2196 ('pRefresherId', _WBEM_REFRESHER_ID),

2197 ('lFlags', LONG),

2198 ('dwClientRefrVersion', DWORD),

2199 )

2200

2201 class IWbemRefreshingServices_GetRemoteRefresherResponse(DCOMANSWER):

2202 structure = (

2203 ('ppRemRefresher', PMInterfacePointer),

2204 ('pGuid', GUID),

2205 ('pdwSvrRefrVersion', DWORD),

2206 ('ErrorCode', error_status_t),

2207 )

2208

2209# 3.1.4.12.6 IWbemRefreshingServices::ReconnectRemoteRefresher (Opnum 8)

2210 class IWbemRefreshingServices_ReconnectRemoteRefresher(DCOMCALL):

2211 opnum = 8

2212 structure = (

2213 ('pRefresherId', _WBEM_REFRESHER_ID),

2214 ('lFlags', LONG),

2215 ('lNumObjects', LONG),

2216 ('dwClientRefrVersion', DWORD),

2217 ('apReconnectInfo', _WBEM_RECONNECT_INFO_ARRAY),

2218 )

2219

2220 class IWbemRefreshingServices_ReconnectRemoteRefresherResponse(DCOMANSWER):

2221 structure = (

2222 ('apReconnectResults', _WBEM_RECONNECT_RESULTS_ARRAY),

2223 ('pdwSvrRefrVersion', DWORD),

2224 ('ErrorCode', error_status_t),

2225 )

2226

2227# 3.1.4.13 IWbemRemoteRefresher Interface

2228# 3.1.4.13.1 IWbemRemoteRefresher::RemoteRefresh (Opnum 3)

2229 class IWbemRemoteRefresher_RemoteRefresh(DCOMCALL):

2230 opnum = 3

2231 structure = (

2232 ('lFlags', LONG),

2233 )

2234

2235 class IWbemRemoteRefresher_RemoteRefreshResponse(DCOMANSWER):

2236 structure = (

2237 ('plNumObjects', _WBEM_RECONNECT_RESULTS_ARRAY),

2238 ('paObjects', PWBEM_REFRESHED_OBJECT_ARRAY),

2239 ('ErrorCode', error_status_t),

2240 )

2241

2242# 3.1.4.13.2 IWbemRemoteRefresher::StopRefreshing (Opnum 4)

2243 class IWbemRemoteRefresher_StopRefreshing(DCOMCALL):

2244 opnum = 4

2245 structure = (

2246 ('lNumIds', LONG),

2247 ('aplIds', PULONG_ARRAY),

2248 ('lFlags', LONG),

2249 )

2250

2251 class IWbemRemoteRefresher_StopRefreshingResponse(DCOMANSWER):

2252 structure = (

2253 ('ErrorCode', error_status_t),

2254 )

2255

2256# 3.1.4.14 IWbemShutdown Interface

2257# 3.1.4.14.1 IWbemShutdown::Shutdown (Opnum 3)

2258 class IWbemShutdown_Shutdown(DCOMCALL):

2259 opnum = 3

2260 structure = (

2261 ('reserved1', LONG),

2262 ('reserved2', ULONG),

2263 ('reserved3', PMInterfacePointer),

2264 )

2265

2266 class IWbemShutdown_ShutdownResponse(DCOMANSWER):

2267 structure = (

2268 ('ErrorCode', error_status_t),

2269 )

2270

2271# 3.1.4.15 IUnsecuredApartment Interface

2272# 3.1.4.15.1 IUnsecuredApartment::CreateObjectStub (Opnum 3)

2273 class IUnsecuredApartment_CreateObjectStub(DCOMCALL):

2274 opnum = 3

2275 structure = (

2276 ('reserved1', PMInterfacePointer),

2277 )

2278

2279 class IUnsecuredApartment_CreateObjectStubResponse(DCOMANSWER):

2280 structure = (

2281 ('reserved2', PMInterfacePointer),

2282 ('ErrorCode', error_status_t),

2283 )

2284

2285# 3.1.4.16 IWbemUnsecuredApartment Interface

2286# 3.1.4.16.1 IWbemUnsecuredApartment::CreateSinkStub (Opnum 3)

2287 class IWbemUnsecuredApartment_CreateSinkStub(DCOMCALL):

2288 opnum = 3

2289 structure = (

2290 ('reserved1', PMInterfacePointer),

2291 ('reserved2', DWORD),

2292 ('reserved3', LPWSTR),

2293 )

2294

2295 class IWbemUnsecuredApartment_CreateSinkStubResponse(DCOMANSWER):

2296 structure = (

2297 ('reserved4', PMInterfacePointer),

2298 ('ErrorCode', error_status_t),

2299 )

2300

2301################################################################################

2302# OPNUMs and their corresponding structures

2303################################################################################

2304 OPNUMS = {

2305}

2306

2307################################################################################

2308# HELPER FUNCTIONS AND INTERFACES

2309################################################################################

2310 def checkNullString(string):

2311 if string == NULL:

2312 return string

2313

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

2315 return string + '\x00'

2316 else:

2317 return string

2318

2319 class IWbemClassObject(IRemUnknown):

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

2321 IRemUnknown.__init__(self,interface)

2322 self._iid = IID_IWbemClassObject

2323 self.__iWbemServices = iWbemServices

2324 self.__methods = None

2325

2326 objRef = self.get_objRef()

2327 objRef = OBJREF_CUSTOM(objRef)

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

2329 self.parseObject()

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

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

2332 else:

2333 self.createProperties(self.getProperties())

2334

2335 def __getattr__(self, attr):

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

2337 properties = self.getProperties()

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

2339 keyProperty = None

2340 for pName in properties:

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

2342 keyProperty = pName

2343

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

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

2346 else:

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

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

2349 self.__methods = classObject.getMethods()

2350

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

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

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

2354 instanceName = '%s.%s=%s' % (

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

2356 else:

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

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

2359

2360 self.createMethods(instanceName , self.__methods)

2361 #print dir(self)

2362 return getattr(self, attr)

2363

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

2365 (self.__class__, attr))

2366

2367 def parseObject(self):

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

2369

2370 def getObject(self):

2371 return self.encodingUnit['ObjectBlock']

2372

2373 def getClassName(self):

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

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

2376 else:

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

2378

2379 def printInformation(self):

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

2381

2382 def getProperties(self):

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

2384 return ()

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

2386

2387 def getMethods(self):

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

2389 return ()

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

2391

2392 @staticmethod

2393 def __ndEntry(index, null_default, inherited_default):

2394 # https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wmio/ed436785-40fc-425e-ad3d-f9200eb1a122

2395 return (bool(null_default) << 1 | bool(inherited_default)) << (2 * index)

2396

2397 def marshalMe(self):

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

2399 # we need to update the values

2400 # That's what we'll do

2401

2402 instanceHeap = b''

2403 valueTable = b''

2404 ndTable = 0

2405 parametersClass = ENCODED_STRING()

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

2407 instanceHeap += parametersClass.getData()

2408 curHeapPtr = len(instanceHeap)

2409 properties = self.getProperties()

2410 for i, propName in enumerate(properties):

2411 propRecord = properties[propName]

2412 itemValue = getattr(self, propName)

2413 propIsInherited = propRecord['inherited']

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

2415

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

2417 if propRecord['type'] & CIM_ARRAY_FLAG:

2418 # Not yet ready

2419 packStr = HEAPREF[:-2]

2420 else:

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

2422

2423 if propRecord['type'] & CIM_ARRAY_FLAG:

2424 if itemValue is None:

2425 ndTable |= self.__ndEntry(i, True, propIsInherited)

2426 valueTable += pack(packStr, 0)

2427 else:

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

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

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

2431 arrayItems = b''

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

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

2434 instanceHeap += arraySize + arrayItems

2435 curHeapPtr = len(instanceHeap)

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

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

2438 if itemValue is None:

2439 ndTable |= self.__ndEntry(i, True, propIsInherited)

2440 valueTable += pack(packStr, 0)

2441 else:

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

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

2444 if itemValue is None:

2445 ndTable |= self.__ndEntry(i, True, propIsInherited)

2446 valueTable += pack(packStr, False)

2447 else:

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

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

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

2451 if itemValue is None:

2452 ndTable |= self.__ndEntry(i, True, propIsInherited)

2453 valueTable += pack(packStr, -1)

2454 else:

2455 valueTable += pack(packStr, itemValue)

2456 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2457 # For now we just pack None and set the inherited_default

2458 # flag, just in case a parent class defines this for us

2459 valueTable += b'\x00'*4

2460 if itemValue is None:

2461 ndTable |= self.__ndEntry(i, True, True)

2462 else:

2463 if itemValue == '':

2464 # https://github.com/SecureAuthCorp/impacket/pull/1069#issuecomment-835179409

2465 # Force inherited_default to avoid 'obscure' issue in wmipersist.py

2466 ndTable |= self.__ndEntry(i, True, True)

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

2468 else:

2469 strIn = ENCODED_STRING()

2470 strIn['Character'] = itemValue

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

2472 instanceHeap += strIn.getData()

2473 curHeapPtr = len(instanceHeap)

2474

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

2476 packedNdTable = b''

2477 for i in range(ndTableLen):

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

2479 ndTable >>= 8

2480

2481 # Now let's update the structure

2482 objRef = self.get_objRef()

2483 objRef = OBJREF_CUSTOM(objRef)

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

2485

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

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

2488

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

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

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

2492

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

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

2495

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

2497

2498 #encodingUnit.dump()

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

2500

2501 objRef['pObjectData'] = encodingUnit

2502

2503 return objRef

2504

2505 def SpawnInstance(self):

2506 # Doing something similar to:

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

2508 #

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

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

2511 encodingUnit = ENCODING_UNIT()

2512

2513 instanceData = OBJECT_BLOCK()

2514 instanceData.structure += OBJECT_BLOCK.decoration

2515 instanceData.structure += OBJECT_BLOCK.instanceType

2516 instanceData['ObjectFlags'] = 6

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

2518

2519 instanceType = INSTANCE_TYPE()

2520 instanceType['CurrentClass'] = b''

2521

2522 # Let's create the heap for the parameters

2523 instanceHeap = b''

2524 valueTable = b''

2525 parametersClass = ENCODED_STRING()

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

2527 instanceHeap += parametersClass.getData()

2528 curHeapPtr = len(instanceHeap)

2529

2530 ndTable = 0

2531 properties = self.getProperties()

2532

2533 # Let's initialize the values

2534 for i, propName in enumerate(properties):

2535 propRecord = properties[propName]

2536

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

2538 if propRecord['type'] & CIM_ARRAY_FLAG:

2539 # Not yet ready

2540 #print paramDefinition

2541 #raise

2542 packStr = HEAPREF[:-2]

2543 else:

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

2545

2546 if propRecord['type'] & CIM_ARRAY_FLAG:

2547 valueTable += pack(packStr, 0)

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

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

2550 valueTable += pack(packStr, 0)

2551 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2552 # For now we just pack None and set the inherited_default

2553 # flag, just in case a parent class defines this for us

2554 valueTable += b'\x00'*4

2555 ndTable |= self.__ndEntry(i, True, True)

2556 else:

2557 strIn = ENCODED_STRING()

2558 strIn['Character'] = ''

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

2560 instanceHeap += strIn.getData()

2561 curHeapPtr = len(instanceHeap)

2562

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

2564 packedNdTable = b''

2565 for i in range(ndTableLen):

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

2567 ndTable >>= 8

2568

2569 instanceType['NdTable_ValueTable'] = packedNdTable + valueTable

2570

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

2572

2573 instanceType['InstanceHeap'] = HEAP()

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

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

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

2577

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

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

2580

2581 encodingUnit['ObjectBlock'] = instanceData

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

2583

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

2585

2586 objRefCustomIn = OBJREF_CUSTOM()

2587 objRefCustomIn['iid'] = self._iid

2588 objRefCustomIn['clsid'] = CLSID_WbemClassObject

2589 objRefCustomIn['cbExtension'] = 0

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

2591 objRefCustomIn['pObjectData'] = encodingUnit

2592

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

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

2595 import copy

2596 newObj = copy.deepcopy(self)

2597 newObj.set_objRef(objRefCustomIn.getData())

2598 newObj.process_interface(objRefCustomIn.getData())

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

2600 newObj.parseObject()

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

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

2603 else:

2604 newObj.createProperties(newObj.getProperties())

2605

2606 return newObj

2607 else:

2608 return self

2609

2610 def createProperties(self, properties):

2611 for property in properties:

2612 # Do we have an object property?

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

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

2615 objRef = OBJREF_CUSTOM()

2616 objRef['iid'] = self._iid

2617 objRef['clsid'] = CLSID_WbemClassObject

2618 objRef['cbExtension'] = 0

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

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

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

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

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

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

2625 value = list()

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

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

2628 objRef = OBJREF_CUSTOM()

2629 objRef['iid'] = self._iid

2630 objRef['clsid'] = CLSID_WbemClassObject

2631 objRef['cbExtension'] = 0

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

2633 objRef['pObjectData'] = item

2634 wbemClass = IWbemClassObject(

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

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

2637 value.append(wbemClass)

2638 else:

2639 value = properties[property]['value']

2640 else:

2641 value = properties[property]['value']

2642 setattr(self, property, value)

2643

2644 def createMethods(self, classOrInstance, methods):

2645 class FunctionPool:

2646 def __init__(self,function):

2647 self.function = function

2648 def __getitem__(self,item):

2649 return partial(self.function,item)

2650

2651 @FunctionPool

2652 def innerMethod(staticArgs, *args):

2653 classOrInstance = staticArgs[0]

2654 methodDefinition = staticArgs[1]

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

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

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

2658 return None

2659 # In Params

2660 encodingUnit = ENCODING_UNIT()

2661

2662 inParams = OBJECT_BLOCK()

2663 inParams.structure += OBJECT_BLOCK.instanceType

2664 inParams['ObjectFlags'] = 2

2665 inParams['Decoration'] = b''

2666

2667 instanceType = INSTANCE_TYPE()

2668 instanceType['CurrentClass'] = b''

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

2670

2671 # Let's create the heap for the parameters

2672 instanceHeap = b''

2673 valueTable = b''

2674 parametersClass = ENCODED_STRING()

2675 parametersClass['Character'] = '__PARAMETERS'

2676 instanceHeap += parametersClass.getData()

2677 curHeapPtr = len(instanceHeap)

2678

2679 ndTable = 0

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

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

2682 inArg = args[i]

2683

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

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

2686 # Not yet ready

2687 #print paramDefinition

2688 #raise

2689 packStr = HEAPREF[:-2]

2690 else:

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

2692

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

2694 if inArg is None:

2695 valueTable += pack(packStr, 0)

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

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

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

2699 arrayItems = []

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

2701 curVal = inArg[j]

2702 if pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

2703 curObject = b''

2704 marshaledObject = curVal.marshalMe()

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

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

2707 arrayItems.append(curObject)

2708 continue

2709 strIn = ENCODED_STRING()

2710 if type(curVal) is str:

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

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

2713 # terminator.

2714 strIn['Encoded_String_Flag'] = 0x1

2715 strIn.structure = strIn.tunicode

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

2717 else:

2718 strIn['Character'] = curVal

2719 arrayItems.append(strIn.getData())

2720

2721

2722 curStrHeapPtr = curHeapPtr + 4

2723 arrayHeapPtrValues = b''

2724 arrayValueTable = b''

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

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

2727 arrayValueTable += arrayItems[j]

2728 curStrHeapPtr += 4

2729

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

2731 instanceHeap += arraySize + arrayHeapPtrValues + arrayValueTable

2732 curHeapPtr = len(instanceHeap)

2733 else:

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

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

2736 instanceHeap += arraySize

2737 for curVal in inArg:

2738 instanceHeap += pack(packStr, curVal)

2739 curHeapPtr = len(instanceHeap)

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

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

2742 valueTable += pack(packStr, inArg)

2743 elif pType == CIM_TYPE_ENUM.CIM_TYPE_OBJECT.value:

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

2745 # For now we just pack None and set the inherited_default

2746 # flag, just in case a parent class defines this for us

2747 valueTable += b'\x00' * 4

2748 ndTable |= self.__ndEntry(i, True, True)

2749 else:

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

2751 marshaledObject = inArg.marshalMe()

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

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

2754 curHeapPtr = len(instanceHeap)

2755 else:

2756 strIn = ENCODED_STRING()

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

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

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

2760 # terminator.

2761 strIn['Encoded_String_Flag'] = 0x1

2762 strIn.structure = strIn.tunicode

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

2764 else:

2765 strIn['Character'] = inArg

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

2767 instanceHeap += strIn.getData()

2768 curHeapPtr = len(instanceHeap)

2769

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

2771

2772 packedNdTable = b''

2773 for i in range(ndTableLen):

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

2775 ndTable >>= 8

2776

2777 instanceType['NdTable_ValueTable'] = packedNdTable + valueTable

2778 heapRecord = HEAP()

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

2780 heapRecord['HeapItem'] = instanceHeap

2781

2782 instanceType['InstanceHeap'] = heapRecord

2783

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

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

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

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

2788 instanceType['CurrentClass'] = inMethods

2789

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

2791

2792 encodingUnit['ObjectBlock'] = inParams

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

2794

2795 objRefCustomIn = OBJREF_CUSTOM()

2796 objRefCustomIn['iid'] = self._iid

2797 objRefCustomIn['clsid'] = CLSID_WbemClassObject

2798 objRefCustomIn['cbExtension'] = 0

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

2800 objRefCustomIn['pObjectData'] = encodingUnit

2801 else:

2802 objRefCustomIn = NULL

2803

2804 ### OutParams

2805 encodingUnit = ENCODING_UNIT()

2806

2807 outParams = OBJECT_BLOCK()

2808 outParams.structure += OBJECT_BLOCK.instanceType

2809 outParams['ObjectFlags'] = 2

2810 outParams['Decoration'] = b''

2811

2812 instanceType = INSTANCE_TYPE()

2813 instanceType['CurrentClass'] = b''

2814 instanceType['NdTable_ValueTable'] = b''

2815 instanceType['InstanceQualifierSet'] = b''

2816 instanceType['InstanceHeap'] = b''

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

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

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

2820

2821

2822 encodingUnit['ObjectBlock'] = outParams

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

2824

2825 objRefCustom = OBJREF_CUSTOM()

2826 objRefCustom['iid'] = self._iid

2827 objRefCustom['clsid'] = CLSID_WbemClassObject

2828 objRefCustom['cbExtension'] = 0

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

2830 objRefCustom['pObjectData'] = encodingUnit

2831 try:

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

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

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

2835 except Exception as e:

2836 if LOG.level == logging.DEBUG:

2837 import traceback

2838 traceback.print_exc()

2839 LOG.error(str(e))

2840

2841 for methodName in methods:

2842 innerMethod.__name__ = methodName

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

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

2845

2846

2847 class IWbemLoginClientID(IRemUnknown):

2848 def __init__(self, interface):

2849 IRemUnknown.__init__(self,interface)

2850 self._iid = IID_IWbemLoginClientID

2851

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

2853 request = IWbemLoginClientID_SetClientInfo()

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

2855 request['lClientProcId'] = lClientProcId

2856 request['lReserved'] = 0

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

2858 return resp

2859

2860 class IWbemLoginHelper(IRemUnknown):

2861 def __init__(self, interface):

2862 IRemUnknown.__init__(self,interface)

2863 self._iid = IID_IWbemLoginHelper

2864

2865 def SetEvent(self, sEventToSet):

2866 request = IWbemLoginHelper_SetEvent()

2867 request['sEventToSet'] = sEventToSet

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

2869 resp.dump()

2870 return resp

2871

2872

2873 class IWbemWCOSmartEnum(IRemUnknown):

2874 def __init__(self, interface):

2875 IRemUnknown.__init__(self,interface)

2876 self._iid = IID_IWbemWCOSmartEnum

2877

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

2879 request = IWbemWCOSmartEnum_Next()

2880 request['proxyGUID'] = proxyGUID

2881 request['lTimeout'] = lTimeout

2882 request['uCount'] = uCount

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

2884 resp.dump()

2885 return resp

2886

2887 class IWbemFetchSmartEnum(IRemUnknown):

2888 def __init__(self, interface):

2889 IRemUnknown.__init__(self,interface)

2890 self._iid = IID_IWbemFetchSmartEnum

2891

2892 def GetSmartEnum(self, lTimeout):

2893 request = IWbemFetchSmartEnum_GetSmartEnum()

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

2895 resp.dump()

2896 return resp

2897

2898 class IWbemCallResult(IRemUnknown):

2899 def __init__(self, interface):

2900 IRemUnknown.__init__(self,interface)

2901 self._iid = IID_IWbemCallResult

2902

2903 def GetResultObject(self, lTimeout):

2904 request = IWbemCallResult_GetResultObject()

2905 request['lTimeout'] = lTimeout

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

2907 resp.dump()

2908 return resp

2909

2910 def GetResultString(self, lTimeout):

2911 request = IWbemCallResult_GetResultString()

2912 request['lTimeout'] = lTimeout

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

2914 resp.dump()

2915 return resp

2916

2917 def GetResultServices(self, lTimeout):

2918 request = IWbemCallResult_GetResultServices()

2919 request['lTimeout'] = lTimeout

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

2921 resp.dump()

2922 return resp

2923

2924 def GetCallStatus(self, lTimeout):

2925 request = IWbemCallResult_GetCallStatus()

2926 request['lTimeout'] = lTimeout

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

2928 return resp['plStatus']

2929

2930 class IEnumWbemClassObject(IRemUnknown):

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

2932 IRemUnknown.__init__(self,interface)

2933 self._iid = IID_IEnumWbemClassObject

2934 self.__iWbemServices = iWbemServices

2935

2936 def Reset(self):

2937 request = IEnumWbemClassObject_Reset()

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

2939 resp.dump()

2940 return resp

2941

2942 def Next(self, lTimeout, uCount):

2943 request = IEnumWbemClassObject_Next()

2944 request['lTimeout'] = lTimeout

2945 request['uCount'] = uCount

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

2947 interfaces = list()

2948 for interface in resp['apObjects']:

2949 interfaces.append(IWbemClassObject(

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

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

2952

2953 return interfaces

2954

2955 def NextAsync(self, lTimeout, pSink):

2956 request = IEnumWbemClassObject_NextAsync()

2957 request['lTimeout'] = lTimeout

2958 request['pSink'] = pSink

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

2960 resp.dump()

2961 return resp

2962

2963 def Clone(self):

2964 request = IEnumWbemClassObject_Clone()

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

2966 resp.dump()

2967 return resp

2968

2969 def Skip(self, lTimeout, uCount):

2970 request = IEnumWbemClassObject_Skip()

2971 request['lTimeout'] = lTimeout

2972 request['uCount'] = uCount

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

2974 resp.dump()

2975 return resp

2976

2977 class IWbemServices(IRemUnknown):

2978 def __init__(self, interface):

2979 IRemUnknown.__init__(self,interface)

2980 self._iid = IID_IWbemServices

2981

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

2983 request = IWbemServices_OpenNamespace()

2984 request['strNamespace']['asData'] = strNamespace

2985 request['lFlags'] = lFlags

2986 request['pCtx'] = pCtx

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

2988 resp.dump()

2989 return resp

2990

2991 def CancelAsyncCall(self,IWbemObjectSink ):

2992 request = IWbemServices_CancelAsyncCall()

2993 request['IWbemObjectSink'] = IWbemObjectSink

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

2995 return resp['ErrorCode']

2996

2997 def QueryObjectSink(self):

2998 request = IWbemServices_QueryObjectSink()

2999 request['lFlags'] = 0

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

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

3002 target=self.get_target())

3003

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

3005 request = IWbemServices_GetObject()

3006 request['strObjectPath']['asData'] = strObjectPath

3007 request['lFlags'] = lFlags

3008 request['pCtx'] = pCtx

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

3010 ppObject = IWbemClassObject(

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

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

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

3014 ppcallResult = IWbemCallResult(

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

3016 target=self.get_target()))

3017 else:

3018 ppcallResult = NULL

3019 return ppObject, ppcallResult

3020

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

3022 request = IWbemServices_GetObjectAsync()

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

3024 request['lFlags'] = lFlags

3025 request['pCtx'] = pCtx

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

3027 resp.dump()

3028 return resp

3029

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

3031 request = IWbemServices_PutClass()

3032 request['pObject'] = pObject

3033 request['lFlags'] = lFlags

3034 request['pCtx'] = pCtx

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

3036 resp.dump()

3037 return resp

3038

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

3040 request = IWbemServices_PutClassAsync()

3041 request['pObject'] = pObject

3042 request['lFlags'] = lFlags

3043 request['pCtx'] = pCtx

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

3045 resp.dump()

3046 return resp

3047

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

3049 request = IWbemServices_DeleteClass()

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

3051 request['lFlags'] = lFlags

3052 request['pCtx'] = pCtx

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

3054 resp.dump()

3055 return resp

3056

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

3058 request = IWbemServices_DeleteClassAsync()

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

3060 request['lFlags'] = lFlags

3061 request['pCtx'] = pCtx

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

3063 resp.dump()

3064 return resp

3065

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

3067 request = IWbemServices_CreateClassEnum()

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

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 CreateClassEnumAsync(self, strSuperClass, lFlags=0, pCtx=NULL):

3076 request = IWbemServices_CreateClassEnumAsync()

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

3078 request['lFlags'] = lFlags

3079 request['pCtx'] = pCtx

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

3081 resp.dump()

3082 return resp

3083

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

3085 request = IWbemServices_PutInstance()

3086

3087 if pInst is NULL:

3088 request['pInst'] = pInst

3089 else:

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

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

3092 request['lFlags'] = lFlags

3093 request['pCtx'] = pCtx

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

3095 return IWbemCallResult(

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

3097 target=self.get_target()))

3098

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

3100 request = IWbemServices_PutInstanceAsync()

3101 request['pInst'] = pInst

3102 request['lFlags'] = lFlags

3103 request['pCtx'] = pCtx

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

3105 resp.dump()

3106 return resp

3107

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

3109 request = IWbemServices_DeleteInstance()

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

3111 request['lFlags'] = lFlags

3112 request['pCtx'] = pCtx

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

3114 return IWbemCallResult(

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

3116 target=self.get_target()))

3117

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

3119 request = IWbemServices_DeleteInstanceAsync()

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

3121 request['lFlags'] = lFlags

3122 request['pCtx'] = pCtx

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

3124 resp.dump()

3125 return resp

3126

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

3128 request = IWbemServices_CreateInstanceEnum()

3129 request['strSuperClass']['asData'] = strSuperClass

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 IEnumWbemClassObject(

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

3136 target=self.get_target()))

3137

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

3139 request = IWbemServices_CreateInstanceEnumAsync()

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

3141 request['lFlags'] = lFlags

3142 request['pCtx'] = pCtx

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

3144 resp.dump()

3145 return resp

3146

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

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

3149 request = IWbemServices_ExecQuery()

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

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

3152 request['lFlags'] = lFlags

3153 request['pCtx'] = pCtx

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

3155 return IEnumWbemClassObject(

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

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

3158

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

3160 request = IWbemServices_ExecQueryAsync()

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

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

3163 request['lFlags'] = lFlags

3164 request['pCtx'] = pCtx

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

3166 resp.dump()

3167 return resp

3168

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

3170 request = IWbemServices_ExecNotificationQuery()

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

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

3173 request['lFlags'] = lFlags

3174 request['pCtx'] = pCtx

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

3176 return IEnumWbemClassObject(

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

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

3179

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

3181 request = IWbemServices_ExecNotificationQueryAsync()

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

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

3184 request['lFlags'] = lFlags

3185 request['pCtx'] = pCtx

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

3187 resp.dump()

3188 return resp

3189

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

3191 request = IWbemServices_ExecMethod()

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

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

3194 request['lFlags'] = lFlags

3195 request['pCtx'] = pCtx

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

3197 request['pInParams'] = pInParams

3198 else:

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

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

3201

3202 request.fields['ppCallResult'] = NULL

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

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

3205 else:

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

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

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

3209 return IWbemClassObject(

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

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

3212

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

3214 request = IWbemServices_ExecMethodAsync()

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

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

3217 request['lFlags'] = lFlags

3218 request['pCtx'] = pCtx

3219 request['pInParams'] = pInParams

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

3221 resp.dump()

3222 return resp

3223

3224 class IWbemLevel1Login(IRemUnknown):

3225 def __init__(self, interface):

3226 IRemUnknown.__init__(self,interface)

3227 self._iid = IID_IWbemLevel1Login

3228

3229 def EstablishPosition(self):

3230 request = IWbemLevel1Login_EstablishPosition()

3231 request['reserved1'] = NULL

3232 request['reserved2'] = 0

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

3234 return resp['LocaleVersion']

3235

3236 def RequestChallenge(self):

3237 request = IWbemLevel1Login_RequestChallenge()

3238 request['reserved1'] = NULL

3239 request['reserved2'] = NULL

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

3241 return resp['reserved3']

3242

3243 def WBEMLogin(self):

3244 request = IWbemLevel1Login_WBEMLogin()

3245 request['reserved1'] = NULL

3246 request['reserved2'] = NULL

3247 request['reserved3'] = 0

3248 request['reserved4'] = NULL

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

3250 return resp['reserved5']

3251

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

3253 request = IWbemLevel1Login_NTLMLogin()

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

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

3256 request['lFlags'] = 0

3257 request['pCtx'] = pCtx

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

3259 return IWbemServices(

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

3261 target=self.get_target()))

3262

3263

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

3265 # Example 1

3266 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'

3267

3268 #encodingUnit = ENCODING_UNIT(baseClass)

3269 #encodingUnit.dump()

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

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

3272

3273 #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"

3274 #hexdump(myClass)

3275 #encodingUnit = ENCODING_UNIT(myClass)

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

3277 #encodingUnit.dump()

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

3279

3280 #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"

3281 #encodingUnit = ENCODING_UNIT(instanceMyClass)

3282 #encodingUnit.dump()

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