45#define ROUND_SIZE(size, alignment) (((size) + ((alignment) - 1)) & ~((alignment) - 1))
47#define ROUNDING(size, alignment) (((alignment) - 1) - (((size) + ((alignment) - 1)) & ((alignment) - 1)))
75static const unsigned short IsPipe = 0x0004;
76static const unsigned short IsIn = 0x0008;
77static const unsigned short IsOut = 0x0010;
88 const char *
name,
unsigned int *typestring_offset);
91 const char *
name,
int write_ptr,
unsigned int *tfsoff);
95 const char *
name,
unsigned int *typestring_offset);
105 case FC_BYTE:
return "FC_BYTE";
106 case FC_CHAR:
return "FC_CHAR";
112 case FC_LONG:
return "FC_LONG";
121 case FC_RP:
return "FC_RP";
122 case FC_UP:
return "FC_UP";
123 case FC_OP:
return "FC_OP";
124 case FC_FP:
return "FC_FP";
151 case FC_IP:
return "FC_IP";
170 case FC_PP:
return "FC_PP";
179 case FC_END:
return "FC_END";
180 case FC_PAD:
return "FC_PAD";
186 error(
"string_of_type: unknown type 0x%02x\n",
type);
398 unsigned short offset = 0;
399 unsigned int salign = 1;
408 unsigned int align = 0;
421 unsigned int stack_size;
440 if (by_value) *by_value = by_val;
447 unsigned char flags = 0;
468 unsigned int flags = 0;
481 int has_conformance = 0;
482 int has_variance = 0;
515 error_loc(
"field '%s' deriving from a conformant array must be the last field in the structure\n",
562 error_loc(
"field '%s' deriving from a conformant array must be the last field in the structure\n",
570 error_loc(
"field '%s' deriving from a conformant array must be the last field in the structure\n",
579 error_loc(
"Unknown struct member %s with type (0x%02x)\n",
field->name,
fc);
603 if ( has_conformance )
608 if( has_conformance && has_pointer )
610 if( has_conformance )
807 unsigned short off = 0;
814 error(
"user_type_offset: couldn't find type (%s)\n",
name);
829 if (
type->typestring_offset)
832 type->typestring_offset = 1;
862#define WRITE_FCTYPE(file, fctype, typestring_offset) \
865 fprintf(file, "/* %2u */\n", typestring_offset); \
866 print_file((file), 2, "0x%02x,\t/* " #fctype " */\n", fctype); \
896 local_var_prefix,
n, local_var_prefix,
n);
943 print_file(
f,
indent,
"static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;\n");
944 print_file(
f,
indent,
"static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;\n");
959 unsigned int *stack_size,
unsigned int *typestring_offset )
962 unsigned char fc = 0;
967 if (is_return) is_out =
TRUE;
968 else if (!is_in && !is_out) is_in =
TRUE;
972 *typestring_offset =
var->typestring_offset;
1012 *typestring_offset =
var->type->typestring_offset;
1022 else *typestring_offset += 2;
1028 *typestring_offset += 4;
1064 *typestring_offset =
ref->typestring_offset;
1080 *typestring_offset =
ref->typestring_offset;
1109 server_size = (server_size + 7) / 8;
1110 if (server_size < 8) *
flags |= server_size << 13;
1120 unsigned char oi2_flags = 0x40;
1121 unsigned short flags;
1122 unsigned int stack_size, typestring_offset;
1147 unsigned int stack_size, typestring_offset;
1148 unsigned short flags;
1173 typestring_offset, typestring_offset );
1179 int is_return,
int is_interpreted)
1186 if (!is_in && !is_out) is_in =
TRUE;
1216 unsigned short offset =
var->typestring_offset;
1220 var->type->details.array.ptr_tfsoff)
1225 else if (is_in && is_out)
1292 unsigned short num_proc )
1296 unsigned char explicit_fc, implicit_fc;
1297 unsigned char handle_flags;
1301 unsigned int nb_args = 0;
1302 unsigned int stack_size = 0;
1303 unsigned short param_num = 0;
1304 unsigned short handle_stack_offset = 0;
1305 unsigned short handle_param_num = 0;
1317 if (
var == handle_var)
1319 handle_stack_offset = stack_size;
1320 handle_param_num = param_num;
1340 print_file(
file,
indent,
"NdrFcShort(0x%x),\t/* stack size = %u */\n", stack_size, stack_size );
1345 switch (explicit_fc)
1352 handle_stack_offset, handle_stack_offset );
1360 handle_stack_offset, handle_stack_offset );
1370 handle_stack_offset, handle_stack_offset );
1381 unsigned char ext_flags = 0;
1386 if (iface == iface->
details.
iface->async_iface) oi2_flags |= 0x20;
1402 unsigned short pos = 0, fpu_mask = 0;
1417 if (
pos >= 16)
break;
1427 unsigned short num_proc )
1433 unsigned char explicit_fc, implicit_fc;
1491 iface = stmt->
u.
type;
1492 if (!pred(iface))
continue;
1566 *typestring_offset += 1;
1575 unsigned char operator_type = 0;
1577 const char *conftype_string =
"field";
1591 error(
"write_conf_or_var_desc: constant value %d is greater than "
1592 "the maximum constant size of %d\n",
expr->cval,
1595 print_file(
file, 2,
"0x%x, /* Corr desc: constant, val = %d */\n",
1606 conftype_string =
"parameter";
1617 conftype_string =
"field pointer";
1622 switch (subexpr->
type)
1625 subexpr = subexpr->
ref;
1631 subexpr = subexpr->
ref;
1638 subexpr = subexpr->
ref;
1645 subexpr = subexpr->
ref;
1652 subexpr = subexpr->
ref;
1663 unsigned char param_type = 0;
1678 correlation_variable =
var->type;
1694 correlation_variable =
var->type;
1701 if (!correlation_variable)
1702 error(
"write_conf_or_var_desc: couldn't find variable %s in %s\n", subexpr->
u.
sval,
name);
1734 error(
"write_conf_or_var_desc: conformance variable type not supported 0x%x\n",
1754 error(
"write_conf_or_var_desc: non-arithmetic type used as correlation variable %s\n",
1768 unsigned int callback_offset = 0;
1788 eval =
xmalloc (
sizeof(*eval));
1798 error(
"Maximum number of callback routines reached\n");
1800 print_file(
file, 2,
"0x%x,\t/* Corr desc: %s in %s */\n", conftype, conftype_string,
name);
1802 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %u */\n", (
unsigned short)callback_offset, callback_offset);
1816 unsigned int align = 0;
1825 unsigned int size = 0;
1826 unsigned int max_align;
1832 unsigned int falign = 0;
1848 unsigned int size, maxs = 0;
1849 unsigned int align = *pmaxa;
1868 unsigned int size = 0;
1921 error(
"type_memsize: Unknown enum type\n");
1977 unsigned int align = 0;
2023 error(
"type_buffer_alignment: Unknown enum type\n");
2030 if (!
var->type)
continue;
2039 if (!
var->type)
continue;
2048 if (!
var->type)
continue;
2090 print_file(
file,
indent,
"__frame->_StubMsg.FullPtrXlatTables = NdrFullPointerXlatInit(0,%s);\n",
2091 is_server ?
"XLAT_SERVER" :
"XLAT_CLIENT");
2105 unsigned int *typeformat_offset)
2107 unsigned int start_offset = *typeformat_offset;
2108 short reloff =
offset - (*typeformat_offset + 2);
2109 int in_attr, out_attr;
2111 unsigned char flags = 0;
2117 if (!in_attr && !out_attr) in_attr = 1;
2121 if (out_attr && !in_attr && pointer_type ==
FC_RP)
2137 if (in_attr && out_attr)
2151 if (pointer_type !=
FC_RP) {
2174 *typeformat_offset += 4;
2176 return start_offset;
2183 unsigned char pointer_fc;
2192 error(
"write_simple_pointer: can't handle type %s which is a string type\n",
type->name);
2204 if (out_attr && !in_attr && pointer_fc ==
FC_RP)
2213 print_file(
file, 2,
"0x%02x, 0x%x,\t/* %s %s[simple_pointer] */\n",
2231 unsigned int *typestring_offset)
2233 unsigned int offset = *typestring_offset;
2256 return type->typestring_offset && !
type->tfswrite;
2332 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Function offset= %hu */\n", funoff, funoff);
2334 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %u */\n", (
unsigned short)usize, usize);
2336 reloff = absoff - *tfsoff;
2337 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n", reloff, reloff, absoff);
2345 unsigned int *tfsoff)
2349 unsigned int absoff;
2359 absoff =
type->typestring_offset;
2361 reloff = absoff - (*tfsoff + 2);
2368 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
2369 reloff, reloff, absoff);
2383 int cont_is_complex,
unsigned int *tfsoff)
2394 ref->typestring_offset, tfsoff);
2414 if (*tfsoff % 2 == 0)
2439 reloff = absoff - (*tfsoff + 6);
2445 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
2446 (
unsigned short)reloff, reloff, absoff);
2455 unsigned int *offset_in_memory,
unsigned int *offset_in_buffer,
2456 unsigned int *typestring_offset)
2463 if (offset_in_memory && offset_in_buffer)
2465 unsigned int memsize;
2472 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Memory offset = %d */\n", (
unsigned short)*offset_in_memory, *offset_in_memory);
2473 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Buffer offset = %d */\n", (
unsigned short)*offset_in_buffer, *offset_in_buffer);
2476 *offset_in_memory += memsize;
2479 *offset_in_buffer += memsize;
2481 *typestring_offset += 4;
2491 ref->typestring_offset, typestring_offset);
2495 error(
"write_pointer_description_offsets: type format string unknown\n");
2499 unsigned int offset =
type->typestring_offset;
2514 offset_in_buffer, typestring_offset);
2522 if (offset_in_memory && offset_in_buffer)
2525 unsigned int align = 0;
2532 file,
v->attrs,
v->type, offset_in_memory, offset_in_buffer,
2538 if (offset_in_memory && offset_in_buffer)
2541 *offset_in_memory += memsize;
2544 *offset_in_buffer += memsize;
2553 unsigned int *offset_in_memory,
unsigned int *offset_in_buffer,
2554 unsigned int *typestring_offset)
2563 *typestring_offset += 2;
2566 offset_in_memory, offset_in_buffer, typestring_offset);
2574 if (offset_in_memory && offset_in_buffer)
2577 unsigned int align = 0;
2585 offset_in_memory, offset_in_buffer, typestring_offset);
2591 *offset_in_memory += memsize;
2594 *offset_in_buffer += memsize;
2604 unsigned int *offset_in_memory,
unsigned int *offset_in_buffer,
2605 unsigned int *typestring_offset)
2607 int pointer_count = 0;
2612 unsigned int temp = 0;
2617 if (pointer_count > 0)
2619 unsigned int increment_size;
2620 unsigned int offset_of_array_pointer_mem = 0;
2621 unsigned int offset_of_array_pointer_buf = 0;
2628 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Increment = %d */\n", (
unsigned short)increment_size, increment_size);
2629 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset to array = %d */\n", (
unsigned short)*offset_in_memory, *offset_in_memory);
2630 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Number of pointers = %d */\n", (
unsigned short)pointer_count, pointer_count);
2631 *typestring_offset += 10;
2634 file, attrs,
type, &offset_of_array_pointer_mem,
2635 &offset_of_array_pointer_buf, typestring_offset);
2643 if (offset_in_memory && offset_in_buffer)
2646 unsigned int align = 0;
2653 file,
v->attrs,
v->type, offset_in_memory, offset_in_buffer,
2659 if (offset_in_memory && offset_in_buffer)
2661 unsigned int memsize;
2663 *offset_in_memory += memsize;
2666 *offset_in_buffer += memsize;
2670 return pointer_count;
2677 unsigned int offset_in_memory,
unsigned int *typestring_offset)
2679 int pointer_count = 0;
2683 unsigned int temp = 0;
2688 if (pointer_count > 0)
2690 unsigned int increment_size;
2691 unsigned int offset_of_array_pointer_mem = offset_in_memory;
2692 unsigned int offset_of_array_pointer_buf = offset_in_memory;
2697 error(
"array size of %u bytes is too large\n", increment_size);
2701 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Increment = %d */\n", (
unsigned short)increment_size, increment_size);
2702 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset to array = %d */\n", (
unsigned short)offset_in_memory, offset_in_memory);
2703 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Number of pointers = %d */\n", (
unsigned short)pointer_count, pointer_count);
2704 *typestring_offset += 8;
2708 &offset_of_array_pointer_mem, &offset_of_array_pointer_buf,
2713 return pointer_count;
2720 unsigned int *offset_in_memory,
unsigned int *offset_in_buffer,
2721 unsigned int *typestring_offset)
2723 int pointer_count = 0;
2727 unsigned int temp = 0;
2732 if (pointer_count > 0)
2734 unsigned int increment_size;
2739 error(
"array size of %u bytes is too large\n", increment_size);
2743 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Increment = %d */\n", (
unsigned short)increment_size, increment_size);
2744 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset to array = %d */\n", (
unsigned short)*offset_in_memory, *offset_in_memory);
2745 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Number of pointers = %d */\n", (
unsigned short)pointer_count, pointer_count);
2746 *typestring_offset += 8;
2750 offset_in_buffer, typestring_offset);
2758 if (offset_in_memory && offset_in_buffer)
2764 *offset_in_buffer =
ROUND_SIZE(*offset_in_buffer, 4);
2766 *offset_in_buffer += 8;
2775 file,
v->attrs,
v->type, offset_in_memory, offset_in_buffer,
2781 if (offset_in_memory && offset_in_buffer)
2784 *offset_in_memory += memsize;
2787 *offset_in_buffer += memsize;
2791 return pointer_count;
2795 unsigned int *typestring_offset)
2797 unsigned int offset_in_buffer;
2798 unsigned int offset_in_memory;
2804 offset_in_memory = 0;
2805 offset_in_buffer = 0;
2808 &offset_in_memory, &offset_in_buffer, typestring_offset);
2812 offset_in_memory = 0;
2813 offset_in_buffer = 0;
2816 &offset_in_memory, &offset_in_buffer, typestring_offset);
2823 file, attrs,
type, 0, typestring_offset);
2833 offset_in_memory = 0;
2834 offset_in_buffer = 0;
2837 &offset_in_memory, &offset_in_buffer, typestring_offset);
2842 const char *
name,
unsigned int *typestring_offset)
2844 unsigned int start_offset;
2845 unsigned char rtype;
2849 start_offset = *typestring_offset;
2856 pointer_type =
FC_RP;
2860 flag ?
" [simple_pointer]" :
"");
2861 *typestring_offset += 2;
2865 *typestring_offset += 2;
2867 is_processed =
FALSE;
2880 error(
"write_string_tfs: Unimplemented for non-basic type %s\n",
name);
2881 return start_offset;
2887 error(
"write_string_tfs: Unimplemented for type 0x%x of name: %s\n", rtype,
name);
2888 return start_offset;
2895 if (is_processed)
return start_offset;
2899 error(
"array size for parameter %s exceeds %u bytes by %u bytes\n",
2900 name, 0xffffu, dim - 0xffffu);
2907 *typestring_offset += 2;
2909 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %d */\n", (
unsigned short)dim, dim);
2910 *typestring_offset += 2;
2913 return start_offset;
2922 *typestring_offset += 2;
2932 return start_offset;
2936 if (is_processed)
return start_offset;
2943 *typestring_offset += 2;
2946 return start_offset;
2951 const char *
name,
unsigned int *typestring_offset)
2957 unsigned int start_offset;
2966 pointer_type =
FC_RP;
2975 start_offset = *typestring_offset;
2980 *typestring_offset += 2;
2988 *typestring_offset += 4;
2993 *typestring_offset += 2;
3009 *typestring_offset += 4;
3013 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %u */\n", (
unsigned short)dim, dim);
3014 *typestring_offset += 2;
3017 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %u */\n", (
unsigned short)elsize, elsize);
3018 *typestring_offset += 2;
3031 *typestring_offset += 2;
3034 *typestring_offset += 1;
3043 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %u */\n", (
unsigned short)dim, dim);
3044 *typestring_offset += 2;
3056 return start_offset;
3062 const var_t *last_field;
3069 ft = last_field->
type;
3081 int is_complex,
unsigned int *corroff,
3082 unsigned int *typestring_offset)
3085 unsigned short offset = 0;
3086 unsigned int salign = 1;
3093 unsigned int align = 0;
3102 unsigned char fc = 0;
3119 *typestring_offset += 1;
3133 *typestring_offset += 1;
3140 const char *
name,
unsigned int *tfsoff)
3143 unsigned int total_size;
3145 unsigned int start_offset;
3147 unsigned int corroff;
3160 error(
"structure size for %s exceeds %d bytes by %d bytes\n",
3178 start_offset = *tfsoff;
3183 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %d */\n", (
unsigned short)total_size, total_size);
3188 unsigned int absoff =
array->type->typestring_offset;
3189 short reloff = absoff - *tfsoff;
3190 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
3191 reloff, reloff, absoff);
3205 unsigned int absoff =
type->ptrdesc ?
type->ptrdesc : *tfsoff;
3206 int reloff = absoff - *tfsoff;
3208 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %d (%u) */\n",
3209 (
unsigned short)reloff, reloff, absoff);
3231 type->ptrdesc = *tfsoff;
3264 if (
type->ptrdesc == *tfsoff)
3269 return start_offset;
3287 print_file(
file, 2,
"NdrFcShort(0x80%02x),\t/* Simple arm type: %s */\n",
3290 else if (
t->typestring_offset)
3292 short reloff =
t->typestring_offset - *tfsoff;
3293 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %d (%d) */\n",
3294 reloff, reloff,
t->typestring_offset);
3306 unsigned int start_offset;
3309 unsigned int nbranch = 0;
3311 short nodeftype = 0xffff;
3317 return type->typestring_offset;
3334 start_offset = *tfsoff;
3341 unsigned int align = 0;
3361 error(
"union switch type must be an integer, char, or enum\n");
3367 error(
"union switch type must be an integer, char, or enum\n");
3404 error(
"union switch type must be an integer, char, or enum\n");
3410 error(
"union switch type must be an integer, char, or enum\n");
3417 print_file(
file, 2,
"NdrFcShort(0x2),\t/* Offset= 2 (%u) */\n", *tfsoff + 2);
3423 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* %d */\n", (
unsigned short)nbranch, nbranch);
3433 if (cases ==
NULL && !deflt)
3434 error(
"union field %s with neither case nor default attribute\n",
f->name);
3466 return start_offset;
3470 unsigned int *typeformat_offset)
3473 unsigned int start_offset = *typeformat_offset;
3501 for (
i = 0;
i < 8; ++
i)
3507 *typeformat_offset += 18;
3509 return start_offset;
3516 unsigned int *typeformat_offset)
3518 unsigned int start_offset = *typeformat_offset;
3526 if (!pointer_type) pointer_type =
FC_RP;
3527 *typeformat_offset += 4;
3529 print_file(
file, 2,
"NdrFcShort(0x2),\t /* Offset= 2 (%u) */\n", *typeformat_offset);
3544 if ((
flags & 0x21) == 0x20)
3546 if ((
flags & 0x21) == 0x21)
3555 *typeformat_offset += 4;
3558 return start_offset;
3563 unsigned int *typeformat_offset)
3566 unsigned int start_offset = *typeformat_offset;
3584 *typeformat_offset += 10;
3586 return start_offset;
3593 unsigned int *typeformat_offset)
3625 unsigned int absoff =
type->typestring_offset;
3626 short reloff = absoff - (*typeformat_offset + 2);
3627 off = *typeformat_offset;
3631 print_file(
file, 2,
"NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n",
3632 reloff, reloff, absoff);
3634 *typeformat_offset += 4;
3636 type->details.array.ptr_tfsoff = off;