dll & offset

Тема в разделе "LANGS.C", создана пользователем NoName, 22 ноя 2011.

  1. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Есть глобальный массив.
    Он во внешней dll.
    Компилятор генерирует
    Код (Text):
    1. mov eax, offset FullProjectIdent
    2. mov eax, offset FullProjectIdent - 4
    обе команды как я понимаю кодируются в одно число. Тогда как должен поступать компилятор при генерации и программист при написании чтобы заработало смещение -4?
    offset ссылается на импорт.
     
  2. TrashGen

    TrashGen ТрещГен

    Публикаций:
    0
    Регистрация:
    15 мар 2011
    Сообщения:
    1.173
    Адрес:
    подполье
    Эти две команды не кодируются в одно число. В еах записывается не один и тот же оффсет, а в целом- нихрена не понятно что вам нужно.
     
  3. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Я имел ввиду что offset будет числом и в первой и второй строке.
    Только во второй строке адрес будет на 4 меньше.
    Вопрос как такая ссылка должна строиться на импорт?
     
  4. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Если смещение прописано как
    Код (Text):
    1. offset FullProjectIdent - 4
    у нас есть проблемный адрес, я непонимаю как он должен правильно выглядить для связи с экспортов другого модуля.
    Если же написано
    Код (Text):
    1. offset FullProjectIdent + 4 * ebx
    , то у нас есть отдельный адрес который указывает на импорт а смещение выясняется в точке вызова. Может быть надо сообщать компилятору о том что это импорт массива чтобы он генерировал правильный код?
     
  5. Magnum

    Magnum New Member

    Публикаций:
    0
    Регистрация:
    29 дек 2007
    Сообщения:
    925
    Стандартная практика для системных модулей 2к и в некоторых случаях ХП.
    Обе длл грузятся по фиксированным адресам, и у них перекрестные офсеты друг на друга.

    В вашем же случае похоже, что идет указатель на таблицу импорта. И оттуда уже идет вызов.
    Что-то вроде:
    mov eax, offset IAT
    call [eax]
    mov eax, offset IAT + 4
    call [eax]

    Присоединяюсь к трешгену. Объясните внятнее, что требуется. Либо уточните вопрос
     
  6. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Есть глобальный массив FullProjectIdent. Он экспортируется из 2.dll в 1.exe.
    В 1.еxe при его использовании компилятор генерирует код, который можно выделить в две группы:
    а. В коде идет адрес, затем независимая от него операция с регистрами для индексации.
    б. В коде идет адрес + некое смещение (4, 8, ..., 128, ...).
    Оба адреса должны указывать на импорт, но второй случай после обработки фиксапов не прокатывает поскольку содержит неверное смещение.

    Мне нужно чтобы код заработал. Возможно я что-то недопонимаю.
    Мое предположение заключается в том что компилятору можно намекнуть ключом командной строки генерировать правильный код, но что-то для Borland 4.5 ненашел пока. Правильно ли я думаю?
    Возможно есть другие версии, предложения?
     
  7. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Ненашел ничего подходящего. При наличии или отсутствии генерации офсеты сохраняются такими же с фиксированными смещениями.

    Код (Text):
    1. Borland 4.5 Command-Line Options
    2. Option  Description
    3.  
    4. +filename   Use alternate configuration file named filename
    5. @filename   Read compiler options from the response file filename
    6.  
    7. -1- Generate 8086 compatible instructions.
    8.  
    9. -1  Generate the 80186/286 compatible instructions (16-bit only).
    10. -2  Generate 80286 protected-mode compatible instructions (16-bit compiler only) (Default for 16-bit)
    11. -3  Generate 80386 protected-mode compatible instructions. (Default for 32-bit compiler)
    12. -4  Generate 80386/80486 protected-mode compatible instructions.
    13. -5  Generate Pentium protected-mode compatible instructions.
    14. -a  Byte alignment. (Default: -a- do not use byte-aligning.)
    15. -A  Use only ANSI keywords. (Extentions like the far and near modifier no longer recognized.)
    16. -AK Use only Kernigham and Ritchie keywords.
    17. -an Align to n. 1=byte, 2=word (2 bytes), 4=double word (4 bytes\2 words 32 bit target only), 8=quad word (8 bytes\4
    18. words 32 bit target only)
    19.  
    20. -AT Use Borland C++ keywords (Alternately specified by -A-)
    21. -AU Use UNIX V keywords. (Extentions like the far and near modifier no longer recognized.)
    22. -B  Compiles assembly and calls TASM or TASM32. If you don't have TASM in your path, checking this option generates
    23. an error. Also, old versions of TASM might have problems with 32-bit generated assembler code.
    24. -b  Make enums always integer-sized. (Default: -b- make enums byte-sized when possible.) Note: Changing this default is
    25. not recommended.
    26. -c  Compiles and assembles the named source files, but does not execute a link command.
    27. -C  Turn nested comments on. (Default: -C- turn nested comments off.)
    28.  
    29. -d  Merge duplicate strings. (Default)
    30. -dc Move string literals from data segment to code segment (16-bit compiler only)
    31. -Didentifier    Define identifier to the null string.
    32. -Didentifier=string Define identifier to string.
    33. -efilename  Derives the executable program's name from filename by adding the file extension .EXE (the program name is then
    34. filename.EXE). filename must immediately follow the -e, with no intervening whitespace. Without this option, the linker
    35. derives the .EXE file's name from the name of the first source or object file in the file name list.
    36. -Efilename  Use filename as the name of the assembler to use. (Default = TASM)
    37. -f  Emulate floating point. (Default)
    38. -f287   Use 80287 hardware instructions (16-bit compiler only).
    39. -F  Uses fast huge pointers.
    40. -Fc Generate COMDEFs (16-bit compiler only).
    41.  
    42. -Ff Create far variables automatically.
    43. -ff Fast floating point. (Default)
    44. -Ff=size    Create far variables automatically; set the threshold to size, where size is 0 to 65535 (16-bit target only).
    45. -Ff=1   Array variable 'identifier' is near warning. (Default)
    46. -Fm Enables all the other -F options (-Fc, -Ff, and -Fs). Use this to quickly port code from other 16-bit compilers.
    47. -Fs Assume DS=SS in all memory models (16-bit compiler only).
    48. -G  Optimize code for speed. (Default: -G- optimize code for size.)
    49. -gn Stop compiling after n messages. (Default: 100.)
    50. -H  Generate and use precompiled headers. (Default)
    51.  
    52. -Hfilename  Sets the name of the file for precompiled headers
    53. -h  This option offers an alternative method of calculating huge pointer expressions; this method is much faster than the
    54. standard method, but must be used with caution. When you use this option, huge pointers are normalized only when a
    55. segment wraparound occurs in the offset part. This causes problems with huge arrays if any array elements cross a
    56. segment boundary.
    57. -H=filename Set the name of the file for precompiled headers to filename.
    58. -Hc Cache precompiled headers. Use with -H, -Hxxx, -Hu, or -Hfilename. This option is useful when compiling more than
    59. one precompiled header. (32-bit compiler only)
    60. -Hu Use but do not generate precompiled headers.
    61. -in Make significant identifier length to be n, where n is between 8 and 250. (Default)
    62. -Ipath  Set search path for directories for include files to path.
    63. -Jg Generate definitions for all template instances and merge duplicates. (Default)
    64. -Jgd    Generate public definitions for all template instances; duplicates result in redefinition errors.
    65.  
    66. -Jgx    Generate external references for all template instances.
    67. -jn Errors: stop after n messages. (Default = 25)
    68. -K  Default character type unsigned. (Default: -K- default character type signed.)
    69. -k  Turn on standard stack frame. (Default)
    70. -K2 Allow only two character types (signed and unsigned). Char is treated as signed. Allows compatibility with Borland
    71. C++ 3.1 and earlier.
    72. -Lpath  Set search path for library files.
    73. -lx Pass option x to the linker (TLINK for BCC and TLINK32 for BCC32). More than one option can appear after the -l
    74. (which is a lowercase L).
    75. -M  Instruct linker to create a full link map.
    76.  
    77. -mc Compile using compact memory model (16-bit compiler only).
    78. -mh Compile using huge memory model.
    79. -ml Compile using large memory model (16-bit compiler only).
    80. -mm Compile using medium memory model (16-bit compiler only).
    81. -mm!    Compile using medium memory model;assume DS!=SS (16-bit compiler only). (Note: there is no space between the
    82. -mm and the !.)
    83. -ms Compile using small memory model (16-bit compiler only). (Default)
    84. -ms!    Compile using small memory model; assume DS! = SS (16-bit compiler only). (Note: there is no space between the
    85. -ms and the !.)
    86. -mt Compile using tiny memory model.
    87. -mt!    Compile using tiny memory model. (Note: there is no space between the -mt and the !.)
    88. -N  Check for stack overflow.
    89.  
    90. -npath  Set the output directory to path.
    91. -O  Optimize jumps.
    92. -O1 Generate smallest possible code (same as using -O, -Ob, -Oe, -Og, -Oi, -Ol, -Om, -Op, -Ot, -Ov, -k-, -Oc, and -Z).
    93. -O2 Generate fastest possible code.
    94. -Oa Optimize assuming pointer expressions are not aliased on common subexpression evaluation.
    95. -Ob Eliminate dead code.
    96. -Oc Eliminate duplicate expressions within basic blocks.
    97. -Od Disable all optimizations.
    98. -Oe Allocate global registers and analyze variable live ranges.
    99.  
    100. -ofilename  Compile source file to filename.OBJ.
    101. -Og Eliminate duplicate expressions within functions.
    102. -Oi Expand common intrinsic functions.
    103. -Ol Compact loops.
    104. -Om Move invariant code out of loops.
    105. -Op Propagate copies.
    106. -Ot Generate fastest code (executable speed); Microsoft compatible.
    107. -Ov Enable loop induction variable and strength reduction.
    108. -OW Suppress the inc bp/dec bp on windows far functions (16-bit compiler only).
    109. -Ox Generate fastest code (executable speed); Microsoft compatible.
    110.  
    111. -P  Perform a C++ compile regardless of source file extension. (Default when extention is not specified. This is an
    112. uppercase P.)
    113. -p  Use Pascal calling convention. (This is a lowercase p.)
    114. -pc Use C calling convention. (Default same as -pc or -p-)
    115. -Pext   Perform a C++ compile regardless of source file extension and set the default extension to ext. This option is available
    116. because some programmers use .C or another extension as their default extension for C++ code.
    117. -po Use fastthis calling convention for passing this parameter in registers (16-bit compiler only).
    118. -pr Use fastcall calling convention for passing parameters in registers.
    119. -ps Use stdcall calling convention (32-bit compiler only).
    120. -R  Include browser information in generated .OBJ files.
    121.  
    122. -r  Use register variables. (Default)
    123. -rd Allow only declared register variables to be kept in registers.
    124. -RT Enable runtime type information. (Default)
    125. -S  Generate assembler source compiles the named source files and produces assembly language output files (.ASM),
    126. but does not assemble. When you use this option, Borland C++ includes the C or C++ source lines as comments in
    127. the produced .ASM file.
    128. -T- Remove all previous assembler options.
    129. -Tstring    Pass string as an option to TASM, TASM32, or assembler specified with -E.
    130. -tW Make the target a Windows .EXE with all functions exportable. (Default)
    131. -tWC    Make the target a console .EXE.
    132. -tWCD   Make the target a console .DLL, all functions exportable
    133. -tWCDE  Make the target a console .DLL, explicit functions exportable
    134. -tWD    Make the target a Windows .DLL with all functions exportable.
    135. -tWDE   Make the target a Windows .DLL with explicit functions exportable.
    136. -tWE    Make the target a Windows .EXE with explicit functions exportable.
    137.  
    138. -tWM    Make a multithreaded application or DLL.
    139. -tWS    Make the target a Windows .EXE that uses smart callbacks (16-bit compiler only).
    140. -tWSE   Make the target a Windows .EXE that uses smart callbacks, with explicit functions exportable and exported (16-bit
    141. compiler only).
    142. -u  Generate underscores for symbols. (Default)
    143. -Uname  Undefines any previous definitions of the named identifier name.
    144. -v  Turn on source debugging.
    145. -V  Create smart C++ virtual tables. (Default)
    146. -V0 Create external C++ virtual tables.
    147. -V1 Create public C++ virtual tables.
    148. -Va Pass class arguments by reference to a temporary variable (16-bit compiler only).
    149. -Vb Make virtual base class pointer the same size as the 'this' pointer of the class (16-bit compiler only). (Default)
    150.  
    151. -Vc Do not add the hidden members and code to classes with pointers to virtual base class members (16-bit compiler
    152. only).
    153. -Vf Far C++ virtual tables (16-bit compiler only).
    154. -Vh Treat 'far' classes as 'huge' (16-bit compiler only) When on, the compiler treats all __far classes as __huge.
    155. -vi Turn on inline expansion (-vi- turns off inline expansion).
    156. -Vmd    Use the smallest representation for member pointers.
    157. -Vmm    Member pointers support multiple inheritance.
    158. -Vmp    Honor the declared precision for all member pointer types.
    159. -Vms    Member pointers support single inheritance.
    160. -Vmv    Member pointers have no restrictions (most general representation). (Default)
    161.  
    162. -Vo Set all backward compatible switches. Use this when linking with libraries built with an older version of Borland C++.
    163. -Vp Pass the 'this' parameter to 'pascal' member functions as the first.
    164. -Vs Local C++ virtual tables.
    165. -Vt Place the virtual table pointer after nonstatic data members (16-bit compiler only).
    166. -Vv This option directs the compiler not to change the layout of any classes (which it needs to do to allow pointers to
    167. virtual base class members, which were not supported in previous versions of Borland C++). If this option is used, the
    168. compiler will not be able to create a pointer to a member of a base class that can be reached only from the derived
    169. class through two or more levels of virtual inheritance.
    170. -W  Creates a Windows GUI application.
    171. -w  Display warnings on.
    172. -w! Do not compile to .OBJ if warnings were found. (Note: there is no space between the -w and the !.)
    173.  
    174. -wamb   Ambiguous operators need parentheses.
    175. -wamp   Superfluous & with function.
    176. -wasm   Unknown assembler instruction.
    177. -waus   'identifier' is assigned a value that is never used. (Default)
    178. -wbbf   Bit fields must be signed or unsigned int.
    179. -wbei   Initializing 'identifier' with 'identifier'. (Default)
    180. -wbig   Hexadecimal value contains more than three digits. (Default)
    181. -WC Creates a 32-bit console mode application.
    182. -wccc   Condition is always true OR Condition is always false. (Default)
    183. -WCD    Creates a 32-bit console mode DLL with all functions exportable and exported.
    184. -WCDE   Creates a 32-bit console mode DLL with explicit functions exportable and exported.
    185. -wcln   Constant is long.
    186.  
    187. -wcpt   Nonportable pointer comparison. (Default)
    188. -WD Creates a GUI DLL with all functions exportable.
    189. -WDE    Creates a GUI DLL with explicit functions exportable and exported.
    190. -wdef   Possible use of 'identifier' before definition.
    191. -wdpu   Declare type 'type' prior to use in prototype (Default)
    192. -wdsz   Array size for 'delete' ignored. (Default)
    193. -wdup   Redefinition of 'macro' is not identical (Default)
    194. -WE Make the target a Windows .EXE with explicit functions exportable and exported.
    195. -weas   'type' assigned to 'enumeration'. (Default)
    196. -weff   Code has no effect. (Default)
    197. -wext   'identifier' is declared as both external and static (Default)
    198. -whch   Handler for '<type1>' Hidden by Previous Handler for '<type2>'
    199. -whid   'function1' hides virtual function 'function2' (Default)
    200. -wibc   Base class '<base1>' is also a base class of '<base2>' (Default)
    201.  
    202. -will   Ill-formed pragma. (Default)
    203. -winl   Functions containing reserved words are not expanded inline (Default)
    204. -wlin   Temporary used to initialize 'identifier'. (Default)
    205. -wlvc   Temporary used for parameter 'parameter' in call to 'function' (Default)
    206. -WM Make a multithreaded application or DLL.
    207. -wmpc   Conversion to type fails for members of virtual base class base. (Default)
    208. -wmpd   Maximum precision used for member pointer type type. (Default)
    209. -wmsg   User-defined warnings . This option allows user-defined messages to appear in the IDE message window.
    210. -wnak   Non-ANSI Keyword Used: '<keyword>' (Note: Use of this option is a requirement for ANSI conformance.)
    211. -wncf   Non-const function 'function' called for const object. (Default)
    212.  
    213. -wnci   The constant member 'identifier' is not initialized. (Default)
    214. -wnod   No declaration for function 'function'
    215. -wnsf   Declaration of static function 'func(...)' ignored.
    216. -wnst   Use qualified name to access nested type 'type' (Default)
    217. -wntd   Use '> >' for nested templates instead of '>>'. (Default)
    218. -wnvf   Non-volatile function function called for volatile object. (Default)
    219. -wobi   Base initialization without a class name is now obsolete (Default)
    220. -wobs   Identifier is obsolete. (Default)
    221. -wofp   Style of function definition is now obsolete. (Default)
    222. -wovl   Overload is now unnecessary and obsolete. (Default)
    223. -wpar   Parameter 'parameter' is never used. (Default)
    224. -wpch   Cannot create precompiled header: header. (Default)
    225. -wpia   Possibly incorrect assignment. (Default)
    226.  
    227. -wpin   Initialization is only partially bracketed.
    228. -wpre   Overloaded prefix operator 'operator' used as a postfix operator.
    229. -wpro   Call to function with no prototype. (Default)
    230. -wrch   Unreachable code. (Default)
    231. -wret   Both return and return of a value used. (Default)
    232. -wrng   Constant out of range in comparison. (Default)
    233. -wrpt   Nonportable pointer conversion. (Default)
    234. -wrvl   Function should return a value. (Default)
    235. -WS Make the target a Windows .EXE that uses smart callbacks (16-bit compiler only).
    236. -WSE    Make the target a Windows .EXE that uses smart callbacks, with explicit functions exportable (16-bit compiler only).
    237. -wsig   Conversion may lose significant digits.
    238. -wstu   Undefined structure 'structure'
    239. -wstv   Structure passed by value.
    240.  
    241. -wsus   Suspicious pointer conversion. (Default)
    242. -wucp   Mixing pointers to different 'char' types.
    243. -wuse   'identifier' declared but never used.
    244. -wvoi   Void functions may not return a value. (Default)
    245. -wxxx   Enable xxx warning message. (Default)
    246. -wzdi   Division by zero (Default)
    247. -X  Disable compiler autodependency output. (Default: -X- use compiler autodependency output.)
    248. -x  Enable exception handling. (Default)
    249. -xc Enable compatible exception handling.
    250. -xd Enable destructor cleanup. (Default)
    251. -xf Enable fast exception prologs.
    252. -xp Enable exception location information.
    253.  
    254. -Y  Generate overlay-compatible code. (16-bit compiler only)
    255. -Yo Overlay compiled files. (16-bit compiler only)
    256. -y  Line numbers on.
    257. -Z  Enable register load suppression optimization.
    258. -zAname Code class set to name.
    259. -zBname BSS class set to name.
    260. -zCname Code segment class set to name.
    261. -zDname BSS segment set to name.
    262. -zEname Far segment set to name (16-bit compiler only).
    263. -zFname Far class set to name (16-bit compiler only).
    264. -zGname BSS group set to name.
    265. -zHname Far group set to name (16-bit compiler only).
    266.  
    267. -zPname Code group set to name.
    268. -zRname Data segment set to name.
    269. -zSname Data group set to name.
    270. -zTname Data class set to name.
    271. -zVname Far virtual segment set to name (16-bit compiler only).
    272. -zWname Far virtual class set to name (16-bit compiler only).
    273. -zX*    Use default name for X. For example, -zA assigns the default class name CODE to the code segment class.
     
  8. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Такая проблема наблюдается для массивов и структур.
     
  9. leo

    leo Active Member

    Публикаций:
    0
    Регистрация:
    4 авг 2004
    Сообщения:
    2.542
    Адрес:
    Russia
    Раз это компилятор генерирует, то покажи (наконец) из чего он это генерирует, т.е. исходник на С
     
  10. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Код (Text):
    1. extern BYTE * FullProjectIdent[];
    2. extern BYTE ** VarTest;
    3. extern BYTE ** VarTest2;
    4.  
    5. void AsmTest(void) {
    6. /*
    7.     push      ebp
    8.     mov       ebp,esp
    9.     add       esp,-52
    10.     push      ebx
    11.  
    12. */
    13.  
    14.    BYTE Buff[ 50 ];
    15.    int i; //не инициализируем т.к. не используем
    16.  
    17.     BYTE c = **VarTest;
    18. /*
    19.     mov       eax,dword ptr [_VarTest]
    20.     mov       eax,dword ptr [eax]
    21.     mov       al,byte ptr [eax]
    22.  
    23. */
    24.  
    25.     *VarTest2[2] = c; //ok
    26. /*
    27. ?live1@48: ; EBX = i, EAX = c
    28.     mov       edx,dword ptr [_VarTest2]
    29.     mov       edx,dword ptr [edx+8]
    30.     mov       byte ptr [edx],al
    31.  
    32. */
    33.  
    34. //  for( i = 0; FullProjectIdent[ i ] != NULL; i++ ) ;
    35.  
    36.   Convert(Buff, (DWORD)&FullProjectIdent[i - 1]); //err
    37. /*
    38. ?live1@60: ; EBX = i
    39.     mov       eax,ebx
    40.     shl       eax,2
    41.     add       eax,offset _FullProjectIdent-4 //проблема именно здесь
    42. //иногда генерируется нормальный код где сначала в регистр кладется offset, а потом с ним производятся любые нормальные действия
    43.     push      eax
    44.     lea       eax,dword ptr [ebp-52]
    45.     push      eax
    46.     call      _Convert
    47.     add       esp,8
    48. */
    49.  
    50. }
     
  11. leo

    leo Active Member

    Публикаций:
    0
    Регистрация:
    4 авг 2004
    Сообщения:
    2.542
    Адрес:
    Russia
    Ну и что ты хочешь? Раз объявляешь статический массив, то его адрес после линковки д.б. известным = const, поэтому ес-но компилятор вправе сразу вычислять и подставлять значений выражений типа const-4 и т.п., т.к. "от перестановки мест слагаемых сумма не меняется".
    Если же речь идет об импорте, то нужно обявлять не сам статический массив, а указатель на него - тогда компилер д.б.сначала загрузить значение ук-ля и только потом прибавлять к нему смещения
     
  12. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    Указатель это здорово, вот только не переписывая существующих программ как их заставить работать.
     
  13. iZzz32

    iZzz32 Sergey Sfeli

    Публикаций:
    0
    Регистрация:
    3 сен 2006
    Сообщения:
    355
    Так что, Borland не умеет dllimport всё же?
     
  14. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    4.5 почему-то пишет что __declspec(dllimport) это функция и дальше кривые параметры
     
  15. iZzz32

    iZzz32 Sergey Sfeli

    Публикаций:
    0
    Регистрация:
    3 сен 2006
    Сообщения:
    355
    Видимо, всё же не поддерживается.
    Зато в bcc32 5.5 есть ключевое слово _import (extern _import BYTE * FullProjectIdent[] – как-то так?). В хелпе 4.5 оно тоже упоминается. Попробуйте? Почему, кстати, используете такой древний компилятор?
     
  16. NoName

    NoName New Member

    Публикаций:
    0
    Регистрация:
    1 авг 2004
    Сообщения:
    1.229
    получилось! , позже отпишусь
     
  17. iZzz32

    iZzz32 Sergey Sfeli

    Публикаций:
    0
    Регистрация:
    3 сен 2006
    Сообщения:
    355
    NoName, попробовал сам в 5.5.1. _import + массив BYTE-ов – ок, _import + массив BYTE * – та самая проблема, без _import – проблема. Но забавно то, что с typedef BYTE * BYTEPTR; extern _import BYTEPTR FullProjectIdent[100]; генерируется верный код (это объектник, EXE не собирал):
    Код (Text):
    1. ; return *FullProjectIdent[0] + *FullProjectIdent[1] + *FullProjectIdent[-1];
    2. mov     eax, dword ptr ds:_FullProjectIdent
    3. mov     edx, [eax]
    4. xor     eax, eax
    5. mov     al, [edx]
    6. mov     edx, dword ptr ds:_FullProjectIdent
    7. mov     ecx, [edx+4]
    8. xor     edx, edx
    9. mov     dl, [ecx]
    10. add     eax, edx
    11. mov     ecx, dword ptr ds:_FullProjectIdent
    12. mov     edx, [ecx-4]
    13. xor     ecx, ecx
    14. mov     cl, [edx]
    15. add     eax, ecx
     
  18. leo

    leo Active Member

    Публикаций:
    0
    Регистрация:
    4 авг 2004
    Сообщения:
    2.542
    Адрес:
    Russia
    iZzz32
    И что тут забавного - неужели не понятно, что экспо- и импо-ртироваться могут только указатели на функции, структуры, массивы, а не сами "тела" этих функций, структур, массивов?!
     
  19. iZzz32

    iZzz32 Sergey Sfeli

    Публикаций:
    0
    Регистрация:
    3 сен 2006
    Сообщения:
    355
    Да, но dllimport/_import скрывают это. Компилятор неявно дереференсит указатель из IAT и extern __declspec(dllimport) int foo; для программиста ведёт себя так, как обычная глобальная переменная.
    Что тут забавного: а разве поведение VOID * foo и PVOID foo должно отличаться?
     
  20. leo

    leo Active Member

    Публикаций:
    0
    Регистрация:
    4 авг 2004
    Сообщения:
    2.542
    Адрес:
    Russia
    iZzz32
    Пардон, погорячился
    Похоже от сишного звездно-заднепроходного синтаксиса не только у меня крыша едет, но и у бцб-шного компилера тоже :) Поэтому мысль заключалась в том, что лучше не пудрить мозги ни себе, ни компилеру и определить тип всего массива через typedef. Но оказалось, что достаточно просто "убрать звездочку" - действительно забавно :)