Added YUV routines needed for v4l driver, and in the future possibly
[wine/gsoc-2012-control.git] / dlls / dbghelp / type.c
blobe7d6928ccfc2e0e03f6c3f66a85a187a4db91cdb
1 /*
2 * File types.c - management of types (hierarchical tree)
4 * Copyright (C) 1997, Eric Youngdale.
5 * 2004, Eric Pouech.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Note: This really doesn't do much at the moment, but it forms the framework
22 * upon which full support for datatype handling will eventually be built.
24 #include "config.h"
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <assert.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winreg.h"
32 #include "winnls.h"
33 #include "wine/debug.h"
34 #include "dbghelp_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
37 WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
39 static const char* symt_get_tag_str(DWORD tag)
41 switch (tag)
43 case SymTagNull: return "SymTagNull";
44 case SymTagExe: return "SymTagExe";
45 case SymTagCompiland: return "SymTagCompiland";
46 case SymTagCompilandDetails: return "SymTagCompilandDetails";
47 case SymTagCompilandEnv: return "SymTagCompilandEnv";
48 case SymTagFunction: return "SymTagFunction";
49 case SymTagBlock: return "SymTagBlock";
50 case SymTagData: return "SymTagData";
51 case SymTagAnnotation: return "SymTagAnnotation";
52 case SymTagLabel: return "SymTagLabel";
53 case SymTagPublicSymbol: return "SymTagPublicSymbol";
54 case SymTagUDT: return "SymTagUDT";
55 case SymTagEnum: return "SymTagEnum";
56 case SymTagFunctionType: return "SymTagFunctionType";
57 case SymTagPointerType: return "SymTagPointerType";
58 case SymTagArrayType: return "SymTagArrayType";
59 case SymTagBaseType: return "SymTagBaseType";
60 case SymTagTypedef: return "SymTagTypedef,";
61 case SymTagBaseClass: return "SymTagBaseClass";
62 case SymTagFriend: return "SymTagFriend";
63 case SymTagFunctionArgType: return "SymTagFunctionArgType,";
64 case SymTagFuncDebugStart: return "SymTagFuncDebugStart,";
65 case SymTagFuncDebugEnd: return "SymTagFuncDebugEnd";
66 case SymTagUsingNamespace: return "SymTagUsingNamespace,";
67 case SymTagVTableShape: return "SymTagVTableShape";
68 case SymTagVTable: return "SymTagVTable";
69 case SymTagCustom: return "SymTagCustom";
70 case SymTagThunk: return "SymTagThunk";
71 case SymTagCustomType: return "SymTagCustomType";
72 case SymTagManagedType: return "SymTagManagedType";
73 case SymTagDimension: return "SymTagDimension";
74 default: return "---";
78 const char* symt_get_name(const struct symt* sym)
80 switch (sym->tag)
82 /* lexical tree */
83 case SymTagData: return ((const struct symt_data*)sym)->hash_elt.name;
84 case SymTagFunction: return ((const struct symt_function*)sym)->hash_elt.name;
85 case SymTagPublicSymbol: return ((const struct symt_public*)sym)->hash_elt.name;
86 case SymTagBaseType: return ((const struct symt_basic*)sym)->hash_elt.name;
87 case SymTagLabel: return ((const struct symt_function_point*)sym)->name;
88 case SymTagThunk: return ((const struct symt_thunk*)sym)->hash_elt.name;
89 /* hierarchy tree */
90 case SymTagEnum: return ((const struct symt_enum*)sym)->name;
91 case SymTagTypedef: return ((const struct symt_typedef*)sym)->hash_elt.name;
92 case SymTagUDT: return ((const struct symt_udt*)sym)->hash_elt.name;
93 default:
94 FIXME("Unsupported sym-tag %s\n", symt_get_tag_str(sym->tag));
95 /* fall through */
96 case SymTagArrayType:
97 case SymTagPointerType:
98 case SymTagFunctionType:
99 return NULL;
103 static struct symt* symt_find_type_by_name(struct module* module,
104 enum SymTagEnum sym_tag,
105 const char* typename)
107 void* ptr;
108 struct symt_ht* type;
109 struct hash_table_iter hti;
111 assert(typename);
112 assert(module);
114 hash_table_iter_init(&module->ht_types, &hti, typename);
115 while ((ptr = hash_table_iter_up(&hti)))
117 type = GET_ENTRY(ptr, struct symt_ht, hash_elt);
119 if ((sym_tag == SymTagNull || type->symt.tag == sym_tag) &&
120 type->hash_elt.name && !strcmp(type->hash_elt.name, typename))
121 return &type->symt;
123 SetLastError(ERROR_INVALID_NAME); /* FIXME ?? */
124 return NULL;
127 static void symt_add_type(struct module* module, struct symt* symt)
129 struct symt** p;
130 p = vector_add(&module->vtypes, &module->pool);
131 assert(p);
132 *p = symt;
135 struct symt_basic* symt_new_basic(struct module* module, enum BasicType bt,
136 const char* typename, unsigned size)
138 struct symt_basic* sym;
140 if (typename)
142 sym = (struct symt_basic*)symt_find_type_by_name(module, SymTagBaseType,
143 typename);
144 if (sym && sym->bt == bt && sym->size == size)
145 return sym;
147 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
149 sym->symt.tag = SymTagBaseType;
150 if (typename)
152 sym->hash_elt.name = pool_strdup(&module->pool, typename);
153 hash_table_add(&module->ht_types, &sym->hash_elt);
154 } else sym->hash_elt.name = NULL;
155 sym->bt = bt;
156 sym->size = size;
157 symt_add_type(module, &sym->symt);
159 return sym;
162 struct symt_udt* symt_new_udt(struct module* module, const char* typename,
163 unsigned size, enum UdtKind kind)
165 struct symt_udt* sym;
167 TRACE_(dbghelp_symt)("Adding udt %s:%s\n", module->module.ModuleName, typename);
168 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
170 sym->symt.tag = SymTagUDT;
171 sym->kind = kind;
172 sym->size = size;
173 if (typename)
175 sym->hash_elt.name = pool_strdup(&module->pool, typename);
176 hash_table_add(&module->ht_types, &sym->hash_elt);
177 } else sym->hash_elt.name = NULL;
178 vector_init(&sym->vchildren, sizeof(struct symt*), 8);
179 symt_add_type(module, &sym->symt);
181 return sym;
184 BOOL symt_set_udt_size(struct module* module, struct symt_udt* udt, unsigned size)
186 assert(udt->symt.tag == SymTagUDT);
187 if (vector_length(&udt->vchildren) != 0)
189 if (udt->size != size)
190 FIXME_(dbghelp_symt)("Changing size for %s from %u to %u\n",
191 udt->hash_elt.name, udt->size, size);
192 return TRUE;
194 udt->size = size;
195 return TRUE;
198 /******************************************************************
199 * symt_add_udt_element
201 * add an element to a udt (struct, class, union)
202 * the size & offset parameters are expressed in bits (not bytes) so that
203 * we can mix in the single call bytes aligned elements (regular fields) and
204 * the others (bit fields)
206 BOOL symt_add_udt_element(struct module* module, struct symt_udt* udt_type,
207 const char* name, struct symt* elt_type,
208 unsigned offset, unsigned size)
210 struct symt_data* m;
211 struct symt** p;
213 assert(udt_type->symt.tag == SymTagUDT);
215 TRACE_(dbghelp_symt)("Adding %s to UDT %s\n", name, udt_type->hash_elt.name);
216 p = NULL;
217 while ((p = vector_iter_up(&udt_type->vchildren, p)))
219 m = (struct symt_data*)*p;
220 assert(m);
221 assert(m->symt.tag == SymTagData);
222 if (m->hash_elt.name[0] == name[0] && strcmp(m->hash_elt.name, name) == 0)
223 return TRUE;
226 if ((m = pool_alloc(&module->pool, sizeof(*m))) == NULL) return FALSE;
227 memset(m, 0, sizeof(*m));
228 m->symt.tag = SymTagData;
229 m->hash_elt.name = pool_strdup(&module->pool, name);
230 m->hash_elt.next = NULL;
232 m->kind = DataIsMember;
233 m->container = &udt_type->symt;
234 m->type = elt_type;
235 m->u.s.offset = offset;
236 m->u.s.length = ((offset & 7) || (size & 7)) ? size : 0;
237 m->u.s.reg_id = 0;
238 p = vector_add(&udt_type->vchildren, &module->pool);
239 *p = &m->symt;
241 return TRUE;
244 struct symt_enum* symt_new_enum(struct module* module, const char* typename)
246 struct symt_enum* sym;
248 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
250 sym->symt.tag = SymTagEnum;
251 sym->name = (typename) ? pool_strdup(&module->pool, typename) : NULL;
252 vector_init(&sym->vchildren, sizeof(struct symt*), 8);
254 return sym;
257 BOOL symt_add_enum_element(struct module* module, struct symt_enum* enum_type,
258 const char* name, int value)
260 struct symt_data* e;
261 struct symt** p;
263 assert(enum_type->symt.tag == SymTagEnum);
264 e = pool_alloc(&module->pool, sizeof(*e));
265 if (e == NULL) return FALSE;
267 e->symt.tag = SymTagData;
268 e->hash_elt.name = pool_strdup(&module->pool, name);
269 e->hash_elt.next = NULL;
270 e->kind = DataIsConstant;
271 e->container = &enum_type->symt;
272 /* CV defines the underlying type for the enumeration */
273 e->type = &symt_new_basic(module, btInt, "int", 4)->symt;
274 e->u.value.n1.n2.vt = VT_I4;
275 e->u.value.n1.n2.n3.lVal = value;
277 p = vector_add(&enum_type->vchildren, &module->pool);
278 if (!p) return FALSE; /* FIXME we leak e */
279 *p = &e->symt;
281 return TRUE;
284 struct symt_array* symt_new_array(struct module* module, int min, int max,
285 struct symt* base)
287 struct symt_array* sym;
289 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
291 sym->symt.tag = SymTagArrayType;
292 sym->start = min;
293 sym->end = max;
294 sym->basetype = base;
295 symt_add_type(module, &sym->symt);
297 return sym;
300 struct symt_function_signature* symt_new_function_signature(struct module* module,
301 struct symt* ret_type)
303 struct symt_function_signature* sym;
305 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
307 sym->symt.tag = SymTagFunctionType;
308 sym->rettype = ret_type;
309 vector_init(&sym->vchildren, sizeof(struct symt*), 4);
310 symt_add_type(module, &sym->symt);
312 return sym;
315 BOOL symt_add_function_signature_parameter(struct module* module,
316 struct symt_function_signature* sig_type,
317 struct symt* param)
319 struct symt** p;
321 assert(sig_type->symt.tag == SymTagFunctionType);
322 p = vector_add(&sig_type->vchildren, &module->pool);
323 if (!p) return FALSE; /* FIXME we leak e */
324 *p = param;
326 return TRUE;
329 struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_type)
331 struct symt_pointer* sym;
333 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
335 sym->symt.tag = SymTagPointerType;
336 sym->pointsto = ref_type;
337 symt_add_type(module, &sym->symt);
339 return sym;
342 struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref,
343 const char* name)
345 struct symt_typedef* sym;
347 if ((sym = pool_alloc(&module->pool, sizeof(*sym))))
349 sym->symt.tag = SymTagTypedef;
350 sym->type = ref;
351 sym->hash_elt.name = pool_strdup(&module->pool, name);
352 hash_table_add(&module->ht_types, &sym->hash_elt);
353 symt_add_type(module, &sym->symt);
355 return sym;
358 /******************************************************************
359 * SymEnumTypes (DBGHELP.@)
362 BOOL WINAPI SymEnumTypes(HANDLE hProcess, ULONG64 BaseOfDll,
363 PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,
364 PVOID UserContext)
366 struct process* pcs;
367 struct module* module;
368 char buffer[sizeof(SYMBOL_INFO) + 256];
369 SYMBOL_INFO* sym_info = (SYMBOL_INFO*)buffer;
370 const char* tmp;
371 struct symt* type;
372 void* pos = NULL;
374 TRACE("(%p %s %p %p)\n",
375 hProcess, wine_dbgstr_longlong(BaseOfDll), EnumSymbolsCallback,
376 UserContext);
378 if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
379 module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
380 if (!(module = module_get_debug(pcs, module))) return FALSE;
382 sym_info->SizeOfStruct = sizeof(SYMBOL_INFO);
383 sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
385 while ((pos = vector_iter_up(&module->vtypes, pos)))
387 type = *(struct symt**)pos;
388 sym_info->TypeIndex = (DWORD)type;
389 sym_info->info = 0; /* FIXME */
390 symt_get_info(type, TI_GET_LENGTH, &sym_info->Size);
391 sym_info->ModBase = module->module.BaseOfImage;
392 sym_info->Flags = 0; /* FIXME */
393 sym_info->Value = 0; /* FIXME */
394 sym_info->Address = 0; /* FIXME */
395 sym_info->Register = 0; /* FIXME */
396 sym_info->Scope = 0; /* FIXME */
397 sym_info->Tag = type->tag;
398 tmp = symt_get_name(type);
399 if (tmp)
401 sym_info->NameLen = min(strlen(tmp),sym_info->MaxNameLen-1);
402 memcpy(sym_info->Name, tmp, sym_info->NameLen);
403 sym_info->Name[sym_info->NameLen] = '\0';
405 else
406 sym_info->Name[sym_info->NameLen = 0] = '\0';
407 if (!EnumSymbolsCallback(sym_info, sym_info->Size, UserContext)) break;
409 return TRUE;
412 /******************************************************************
413 * symt_get_info
415 * Retrieves inforamtion about a symt (either symbol or type)
417 BOOL symt_get_info(const struct symt* type, IMAGEHLP_SYMBOL_TYPE_INFO req,
418 void* pInfo)
420 unsigned len;
422 if (!type) return FALSE;
424 /* helper to typecast pInfo to its expected type (_t) */
425 #define X(_t) (*((_t*)pInfo))
427 switch (req)
429 case TI_FINDCHILDREN:
431 const struct vector* v;
432 struct symt** pt;
433 unsigned i;
434 TI_FINDCHILDREN_PARAMS* tifp = pInfo;
436 switch (type->tag)
438 case SymTagUDT: v = &((const struct symt_udt*)type)->vchildren; break;
439 case SymTagEnum: v = &((const struct symt_enum*)type)->vchildren; break;
440 case SymTagFunctionType: v = &((const struct symt_function_signature*)type)->vchildren; break;
441 case SymTagFunction: v = &((const struct symt_function*)type)->vchildren; break;
442 default:
443 FIXME("Unsupported sym-tag %s for find-children\n",
444 symt_get_tag_str(type->tag));
445 return FALSE;
447 for (i = 0; i < tifp->Count; i++)
449 if (!(pt = vector_at(v, tifp->Start + i))) return FALSE;
450 tifp->ChildId[i] = (DWORD)*pt;
453 break;
455 case TI_GET_ADDRESS:
456 switch (type->tag)
458 case SymTagData:
459 switch (((const struct symt_data*)type)->kind)
461 case DataIsGlobal:
462 case DataIsFileStatic:
463 X(ULONG64) = ((const struct symt_data*)type)->u.address;
464 break;
465 default: return FALSE;
467 break;
468 case SymTagFunction:
469 X(ULONG64) = ((const struct symt_function*)type)->address;
470 break;
471 case SymTagPublicSymbol:
472 X(ULONG64) = ((const struct symt_public*)type)->address;
473 break;
474 case SymTagFuncDebugStart:
475 case SymTagFuncDebugEnd:
476 case SymTagLabel:
477 X(ULONG64) = ((const struct symt_function_point*)type)->parent->address +
478 ((const struct symt_function_point*)type)->offset;
479 break;
480 case SymTagThunk:
481 X(ULONG64) = ((const struct symt_thunk*)type)->address;
482 break;
483 default:
484 FIXME("Unsupported sym-tag %s for get-address\n",
485 symt_get_tag_str(type->tag));
486 return FALSE;
488 break;
490 case TI_GET_BASETYPE:
491 switch (type->tag)
493 case SymTagBaseType:
494 X(DWORD) = ((const struct symt_basic*)type)->bt;
495 break;
496 case SymTagEnum:
497 X(DWORD) = btInt;
498 break;
499 default:
500 return FALSE;
502 break;
504 case TI_GET_BITPOSITION:
505 if (type->tag != SymTagData ||
506 ((const struct symt_data*)type)->kind != DataIsMember ||
507 ((const struct symt_data*)type)->u.s.length == 0)
508 return FALSE;
509 X(DWORD) = ((const struct symt_data*)type)->u.s.offset & 7;
510 break;
512 case TI_GET_CHILDRENCOUNT:
513 switch (type->tag)
515 case SymTagUDT:
516 X(DWORD) = vector_length(&((const struct symt_udt*)type)->vchildren);
517 break;
518 case SymTagEnum:
519 X(DWORD) = vector_length(&((const struct symt_enum*)type)->vchildren);
520 break;
521 case SymTagFunctionType:
522 X(DWORD) = vector_length(&((const struct symt_function_signature*)type)->vchildren);
523 break;
524 case SymTagFunction:
525 X(DWORD) = vector_length(&((const struct symt_function*)type)->vchildren);
526 break;
527 case SymTagPointerType: /* MS does it that way */
528 case SymTagArrayType: /* MS does it that way */
529 case SymTagThunk: /* MS does it that way */
530 X(DWORD) = 0;
531 break;
532 default:
533 FIXME("Unsupported sym-tag %s for get-children-count\n",
534 symt_get_tag_str(type->tag));
535 /* fall through */
536 case SymTagData:
537 case SymTagPublicSymbol:
538 case SymTagBaseType:
539 return FALSE;
541 break;
543 case TI_GET_COUNT:
544 /* it seems that FunctionType also react to GET_COUNT (same value as
545 * GET_CHILDREN_COUNT ?, except for C++ methods, where it seems to
546 * also include 'this' (GET_CHILDREN_COUNT+1)
548 if (type->tag != SymTagArrayType) return FALSE;
549 X(DWORD) = ((const struct symt_array*)type)->end -
550 ((const struct symt_array*)type)->start + 1;
551 break;
553 case TI_GET_DATAKIND:
554 if (type->tag != SymTagData) return FALSE;
555 X(DWORD) = ((const struct symt_data*)type)->kind;
556 break;
558 case TI_GET_LENGTH:
559 switch (type->tag)
561 case SymTagBaseType:
562 X(DWORD) = ((const struct symt_basic*)type)->size;
563 break;
564 case SymTagFunction:
565 X(DWORD) = ((const struct symt_function*)type)->size;
566 break;
567 case SymTagPointerType:
568 X(DWORD) = sizeof(void*);
569 break;
570 case SymTagUDT:
571 X(DWORD) = ((const struct symt_udt*)type)->size;
572 break;
573 case SymTagEnum:
574 X(DWORD) = sizeof(int); /* FIXME: should be size of base-type of enum !!! */
575 break;
576 case SymTagData:
577 if (((const struct symt_data*)type)->kind != DataIsMember ||
578 !((const struct symt_data*)type)->u.s.length)
579 return FALSE;
580 X(DWORD) = ((const struct symt_data*)type)->u.s.length;
581 break;
582 case SymTagArrayType:
583 if (!symt_get_info(((const struct symt_array*)type)->basetype,
584 TI_GET_LENGTH, pInfo))
585 return FALSE;
586 X(DWORD) *= ((const struct symt_array*)type)->end -
587 ((const struct symt_array*)type)->start + 1;
588 break;
589 case SymTagPublicSymbol:
590 X(DWORD) = ((const struct symt_public*)type)->size;
591 break;
592 case SymTagTypedef:
593 return symt_get_info(((const struct symt_typedef*)type)->type, TI_GET_LENGTH, pInfo);
594 case SymTagThunk:
595 X(DWORD) = ((const struct symt_thunk*)type)->size;
596 break;
597 default:
598 FIXME("Unsupported sym-tag %s for get-length\n",
599 symt_get_tag_str(type->tag));
600 /* fall through */
601 case SymTagFunctionType:
602 return 0;
604 break;
606 case TI_GET_LEXICALPARENT:
607 switch (type->tag)
609 case SymTagBlock:
610 X(DWORD) = (DWORD)((const struct symt_block*)type)->container;
611 break;
612 case SymTagData:
613 X(DWORD) = (DWORD)((const struct symt_data*)type)->container;
614 break;
615 case SymTagFunction:
616 X(DWORD) = (DWORD)((const struct symt_function*)type)->container;
617 break;
618 case SymTagThunk:
619 X(DWORD) = (DWORD)((const struct symt_thunk*)type)->container;
620 break;
621 default:
622 FIXME("Unsupported sym-tag %s for get-lexical-parent\n",
623 symt_get_tag_str(type->tag));
624 return FALSE;
626 break;
628 case TI_GET_NESTED:
629 switch (type->tag)
631 case SymTagUDT:
632 case SymTagEnum:
633 X(DWORD) = 0;
634 break;
635 default:
636 return FALSE;
638 break;
640 case TI_GET_OFFSET:
641 switch (type->tag)
643 case SymTagData:
644 switch (((const struct symt_data*)type)->kind)
646 case DataIsParam:
647 case DataIsLocal:
648 case DataIsMember:
649 X(ULONG) = ((const struct symt_data*)type)->u.s.offset >> 3;
650 break;
651 default:
652 FIXME("Unknown kind (%u) for get-offset\n",
653 ((const struct symt_data*)type)->kind);
654 return FALSE;
656 break;
657 default:
658 FIXME("Unsupported sym-tag %s for get-offset\n",
659 symt_get_tag_str(type->tag));
660 return FALSE;
662 break;
664 case TI_GET_SYMNAME:
666 const char* name = symt_get_name(type);
667 if (!name) return FALSE;
668 len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
669 X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
670 if (!X(WCHAR*)) return FALSE;
671 MultiByteToWideChar(CP_ACP, 0, name, -1, X(WCHAR*), len);
673 break;
675 case TI_GET_SYMTAG:
676 X(DWORD) = type->tag;
677 break;
679 case TI_GET_TYPE:
680 case TI_GET_TYPEID:
681 switch (type->tag)
683 /* hierarchical => hierarchical */
684 case SymTagArrayType:
685 X(DWORD) = (DWORD)((const struct symt_array*)type)->basetype;
686 break;
687 case SymTagPointerType:
688 X(DWORD) = (DWORD)((const struct symt_pointer*)type)->pointsto;
689 break;
690 case SymTagFunctionType:
691 X(DWORD) = (DWORD)((const struct symt_function_signature*)type)->rettype;
692 break;
693 case SymTagTypedef:
694 X(DWORD) = (DWORD)((const struct symt_typedef*)type)->type;
695 break;
696 /* lexical => hierarchical */
697 case SymTagData:
698 X(DWORD) = (DWORD)((const struct symt_data*)type)->type;
699 break;
700 case SymTagFunction:
701 X(DWORD) = (DWORD)((const struct symt_function*)type)->type;
702 break;
703 /* FIXME: should also work for enums and FunctionArgType */
704 default:
705 FIXME("Unsupported sym-tag %s for get-type\n",
706 symt_get_tag_str(type->tag));
707 case SymTagThunk:
708 return FALSE;
710 break;
712 case TI_GET_UDTKIND:
713 if (type->tag != SymTagUDT) return FALSE;
714 X(DWORD) = ((const struct symt_udt*)type)->kind;
715 break;
717 case TI_GET_VALUE:
718 if (type->tag != SymTagData || ((const struct symt_data*)type)->kind != DataIsConstant)
719 return FALSE;
720 X(VARIANT) = ((const struct symt_data*)type)->u.value;
721 break;
723 #undef X
725 case TI_GET_ADDRESSOFFSET:
726 case TI_GET_ARRAYINDEXTYPEID:
727 case TI_GET_CALLING_CONVENTION:
728 case TI_GET_CLASSPARENTID:
729 case TI_GET_SYMINDEX:
730 case TI_GET_THISADJUST:
731 case TI_GET_VIRTUALBASECLASS:
732 case TI_GET_VIRTUALBASEPOINTEROFFSET:
733 case TI_GET_VIRTUALTABLESHAPEID:
734 case TI_IS_EQUIV_TO:
735 FIXME("Unsupported GetInfo request (%u)\n", req);
736 return FALSE;
739 return TRUE;
742 /******************************************************************
743 * SymGetTypeInfo (DBGHELP.@)
746 BOOL WINAPI SymGetTypeInfo(HANDLE hProcess, DWORD64 ModBase,
747 ULONG TypeId, IMAGEHLP_SYMBOL_TYPE_INFO GetType,
748 PVOID pInfo)
750 struct process* pcs = process_find_by_handle(hProcess);
751 struct module* module;
753 if (!pcs) return FALSE;
755 module = module_find_by_addr(pcs, ModBase, DMT_UNKNOWN);
756 if (!(module = module_get_debug(pcs, module)))
758 FIXME("Someone didn't properly set ModBase (%s)\n", wine_dbgstr_longlong(ModBase));
759 return FALSE;
762 return symt_get_info((struct symt*)TypeId, GetType, pInfo);
765 /******************************************************************
766 * SymGetTypeFromName (DBGHELP.@)
769 BOOL WINAPI SymGetTypeFromName(HANDLE hProcess, ULONG64 BaseOfDll,
770 LPSTR Name, PSYMBOL_INFO Symbol)
772 struct process* pcs = process_find_by_handle(hProcess);
773 struct module* module;
774 struct symt* type;
776 if (!pcs) return FALSE;
777 module = module_find_by_addr(pcs, BaseOfDll, DMT_UNKNOWN);
778 if (!module) return FALSE;
779 type = symt_find_type_by_name(module, SymTagNull, Name);
780 if (!type) return FALSE;
781 Symbol->TypeIndex = (DWORD)type;
783 return TRUE;