首页
社区
课程
招聘
[求助]关于GUID
发表于: 2010-1-26 10:47 5400

[求助]关于GUID

2010-1-26 10:47
5400
一直搞不明白,在asm中如何调用com,最近看了一些com in asm,模糊有个大概的概念了,也想自己参照写一个,但是那个GUID从何而来,如何手动算出,一直不得其解,google和baidu也无法找到相关内容,特来请教各位大大,希望大大们能为俺解惑,谢谢各位大大。
附google到的一份ASM中调用WMI的例子:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
.586
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
 
INCLUDE windows.inc
INCLUDE kernel32.inc
INCLUDE ole32.inc
INCLUDE msvcrt.inc
;INCLUDE gel32.inc
 
INCLUDELIB kernel32.lib
INCLUDELIB ole32.lib
INCLUDELIB msvcrt.lib
;INCLUDELIB gel32.lib
 
INCLUDE ucmacros.asm
 
; located in ObjIdl.h
 
EOAC_NONE   EQU 0
 
; located in RpcDce.h
 
RPC_C_AUTHN_LEVEL_DEFAULT   EQU 0
RPC_C_IMP_LEVEL_DEFAULT     EQU 0
 
RPC_C_IMP_LEVEL_IMPERSONATE EQU 3
 
GUID2 STRUC
     dd1 DWORD ?
     dw1 WORD ?
     dw2 WORD ?
     db1 BYTE ?
     db2 BYTE ?
     db3 BYTE ?
     db4 BYTE ?
     db5 BYTE ?
     db6 BYTE ?
     db7 BYTE ?
     db8 BYTE ?
GUID2 ENDS
 
IWbemLocator STRUCT
    lpVtbl DWORD   ?
IWbemLocator ENDS
 
IWbemLocatorVtbl STRUCT
    QueryInterface DWORD   ?
    AddRef         DWORD   ?
    Release        DWORD   ?
    ConnectServer  DWORD   ?
IWbemLocatorVtbl ENDS
 
IWbemServices STRUCT
    lpVtbl DWORD   ?
IWbemServices ENDS
 
IWbemServicesVtbl STRUCT
    QueryInterface             DWORD   ?
    AddRef                     DWORD   ?
    Release                    DWORD   ?
    OpenNamespace              DWORD   ?
    CancelAsyncCall            DWORD   ?
    QueryObjectSink            DWORD   ?
    GetObject                  DWORD   ?
    GetObjectAsync             DWORD   ?
    PutClass                   DWORD   ?
    PutClassAsync              DWORD   ?
    DeleteClass                DWORD   ?
    DeleteClassAsync           DWORD   ?
    CreateClassEnum            DWORD   ?
    CreateClassEnumAsync       DWORD   ?
    PutInstance                DWORD   ?
    PutInstanceAsync           DWORD   ?
    DeleteInstance             DWORD   ?
    DeleteInstanceAsync        DWORD   ?
    CreateInstanceEnum         DWORD   ?
    CreateInstanceEnumAsync    DWORD   ?
    ExecQuery                  DWORD   ?
    ExecQueryAsync             DWORD   ?
    ExecNotificationQuery      DWORD   ?
    ExecNotificationQueryAsync DWORD   ?
    ExecMethod                 DWORD   ?
    ExecMethodAsync            DWORD   ?
IWbemServicesVtbl ENDS
 
IEnumWbemClassObject STRUCT
    lpVtbl          DWORD   ?
IEnumWbemClassObject ENDS
 
IEnumWbemClassObjectVtbl STRUCT
    QueryInterface DWORD   ?
    AddRef         DWORD   ?
    Release        DWORD   ?
    Reset          DWORD   ?
    Next           DWORD   ?
    NextAsync      DWORD   ?
    Clone          DWORD   ?
    Skip           DWORD   ?
IEnumWbemClassObjectVtbl ENDS
 
IWbemClassObject STRUCT
    lpVtbl DWORD   ?
IWbemClassObject ENDS
 
IWbemClassObjectVtbl STRUCT
    QueryInterface          DWORD   ?
    AddRef                  DWORD   ?
    Release                 DWORD   ?
    GetQualifierSet         DWORD   ?
    Get                     DWORD   ?
    Put                     DWORD   ?
    Delete                  DWORD   ?
    GetNames                DWORD   ?
    BeginEnumeration        DWORD   ?
    Next                    DWORD   ?
    EndEnumeration          DWORD   ?
    GetPropertyQualifierSet DWORD   ?
    GetObjectText           DWORD   ?
    SpawnDerivedClass       DWORD   ?
    SpawnInstance           DWORD   ?
    CompareTo               DWORD   ?
    GetPropertyOrigin       DWORD   ?
    InheritsFrom            DWORD   ?
    GetMethod               DWORD   ?
    PutMethod               DWORD   ?
    DeleteMethod            DWORD   ?
    BeginMethodEnumeration  DWORD   ?
    NextMethod              DWORD   ?
    EndMethodEnumeration    DWORD   ?
    GetMethodQualifierSet   DWORD   ?
    GetMethodOrigin         DWORD   ?
IWbemClassObjectVtbl ENDS
 
SAFEARRAYBOUND struct
cElements dd ?
lLbound dd ?
SAFEARRAYBOUND ends
    
SAFEARRAY    struct
cDims dw ?
fFeatures dw ?
cbElements dd ?
cLocks dd ?
pvData dd ?
rgsabound SAFEARRAYBOUND <>
SAFEARRAY ends
 
.CONST
    
    wszSelect  WORD "S","E","L","E","C","T"," ","*"," ","F","R","O","M"," ",0  ; the WSTR macro can't handle the asterisk
    wszCrLf    WORD 13,10,0
 
 
    WSTR        wszClass,    "Win32_BIOS"    ;<<< Set class here
    WSTR        wszProperty, "BIOSVersion"  ;<<< Set property here
 
    WSTR        wszNameSpace, "root\cimv2"
    WSTR        wszQueryLanguage, "WQL"
    
    WSTR        wszMsg, "Serial Number %i: %s"
    
WaitKeyW proto :PTR WORD
.DATA
 
    ; located in WbemCli.h
    
    WBEM_FLAG_CONNECT_USE_MAX_WAIT  EQU     80h
    WBEM_FLAG_FORWARD_ONLY          EQU     20h
    WBEM_INFINITE                   EQU     -1
    WBEM_E_INVALID_QUERY            EQU     80041017h
    WBEM_E_INVALID_QUERY_TYPE       EQU     80041018h
    
    IID_IWbemLocator                GUID2   <0dc12a687h,0737fh,011cfh,088h,04dh,000h,0aah,000h,04bh,02eh,024h>
    
    IID_IEnumWbemClassObject        GUID2   <027947e1h,0d731h,011ceh,0a3h,057h,000h,000h,000h,000h,000h,001h>
    
    IID_IWbemClassObject            GUID2   <0dc12a681h,0737fh,011cfh,088h,04dh,000h,0aah,000h,04bh,02eh,024h>
    
    ; located in WbemProv.h
    
    CLSID_WbemAdministrativeLocator GUID2   <0cb8555cch,09128h,011d1h,0adh,09bh,000h,0c0h,04fh,0d8h,0fdh,0ffh>
    
    locator     IWbemLocator            <>
    service     IWbemServices           <>
    enumerator  IEnumWbemClassObject    <>
    processor   IWbemClassObject        <>
    
    retCount    DWORD   ?
    
    var_val     DWORD   ?
                DWORD   ?
                DWORD   ?
                DWORD   ?
 
 
    pwszResult  PWORD   ?            
                
    wszQuery   WORD 256 dup(?)              
 
.CODE
 
  main:
    
    INVOKE CoInitializeEx, NULL, COINIT_MULTITHREADED
    
    INVOKE CoInitializeSecurity, NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL
        
    INVOKE CoCreateInstance, ADDR CLSID_WbemAdministrativeLocator, NULL, CLSCTX_INPROC_SERVER, ADDR IID_IWbemLocator, ADDR locator
 
    INVOKE lstrcatW, ADDR wszQuery, ADDR wszSelect
    INVOKE lstrcatW, ADDR wszQuery, ADDR wszClass
    
    mov esi, locator
    lodsd
    push    OFFSET service
    push    NULL
    push    NULL
    push    WBEM_FLAG_CONNECT_USE_MAX_WAIT
    push    NULL
    push    NULL
    push    NULL
    push    OFFSET wszNameSpace
    push    DWORD PTR [locator]
    call    DWORD PTR [eax][IWbemLocatorVtbl.ConnectServer]
 
    mov esi, service
    lodsd
    push    OFFSET enumerator
    push    NULL
    push    WBEM_FLAG_FORWARD_ONLY
    push    OFFSET wszQuery
    push    OFFSET wszQueryLanguage
    push    DWORD PTR [service]
    call    DWORD PTR [eax][IWbemServicesVtbl.ExecQuery]
 
    mov esi, enumerator
    lodsd
    push    OFFSET retCount
    push    OFFSET processor
    push    TRUE
    push    WBEM_INFINITE
    push    DWORD PTR [enumerator]
    call    DWORD PTR [eax][IEnumWbemClassObjectVtbl.Next]
    
    mov esi, processor
    lodsd
    push    NULL
    push    NULL
    push    OFFSET var_val
    push    0
    push    OFFSET wszProperty
    push    DWORD PTR [processor]
    call    DWORD PTR [eax][IWbemClassObjectVtbl.Get]
    
    mov esi, [var_val]
    mov edi, [var_val + 4]
    mov ecx, [var_val + 8]
    
    mov pwszResult, ecx
 
mov esi,[ecx].SAFEARRAY.pvData
mov edi,[ecx].SAFEARRAY.rgsabound.cElements
 
    INVOKE crt_wprintf, ADDR wszCrLf
     
     
 
    
.while edi
  mov ecx,[esi]
  INVOKE crt_wprintf, ADDR wszMsg, edi,ecx
  INVOKE crt_wprintf, ADDR wszCrLf
dec edi
   add esi,4
.endw
 
 
 
    INVOKE crt_wprintf, ADDR wszCrLf
 
    INVOKE CoUninitialize
    
    INVOKE WaitKeyW, uni$("Press any key to exit ...")
    
    INVOKE ExitProcess, 0
 
WaitKeyW PROC pwszPrompt:PTR WORD
    .DATA
        IFNDEF wszCrLf
            wszCrLf WORD 13,10,0
        ENDIF
    .CODE  
    .IF pwszPrompt == NULL
        INVOKE crt_wprintf, ADDR wszCrLf
        INVOKE crt_wprintf, uni$("Press any key to continue ... ")
    .ELSE
        INVOKE crt_wprintf, ADDR wszCrLf
        INVOKE crt_wprintf, pwszPrompt
    .ENDIF  
    INVOKE crt__getch
    .IF (eax == 0) || (eax == 0E0h)
        INVOKE crt__getch
    .ENDIF
    INVOKE crt_wprintf, ADDR wszCrLf
    ret
WaitKeyW ENDP
;======================================================
    
END main

[注意]看雪招聘,专注安全领域的专业人才平台!

收藏
免费
支持
分享
最新回复 (4)
雪    币: 1259
活跃值: (38)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
stu
2
IID_IWbemLocator                GUID2   <0dc12a687h,0737fh,011cfh,088h,04dh,000h,0aah,000h,04bh,02eh,024h>
   
    IID_IEnumWbemClassObject        GUID2   <027947e1h,0d731h,011ceh,0a3h,057h,000h,000h,000h,000h,000h,001h>
   
    IID_IWbemClassObject            GUID2   <0dc12a681h,0737fh,011cfh,088h,04dh,000h,0aah,000h,04bh,02eh,024h>
   
    ; located in WbemProv.h
   
    CLSID_WbemAdministrativeLocator GUID2   <0cb8555cch,09128h,011d1h,0adh,09bh,000h,0c0h,04fh,0d8h,0fdh,0ffh>
这些GUID和在注册表中找到的不一样,不知道是如何算出来的呢?
2010-1-26 10:48
0
雪    币: 1259
活跃值: (38)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
stu
3
顶起来.
顶起来。
2010-1-26 21:03
0
雪    币: 1259
活跃值: (38)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
stu
4
学坏容易学好难啊。
2010-1-27 22:16
0
雪    币: 37
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
好像c++目录下有一个工具可以生成GUID, 在bin下
2010-1-29 07:24
0
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册