Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly MASM x86快速调用函数声明。。。怎样?_Assembly_X86_Declaration_Masm_Fastcall - Fatal编程技术网

Assembly MASM x86快速调用函数声明。。。怎样?

Assembly MASM x86快速调用函数声明。。。怎样?,assembly,x86,declaration,masm,fastcall,Assembly,X86,Declaration,Masm,Fastcall,我正在尝试将VisualStudio 2010 C程序调用作为fastcall约定汇编例程 这是C代码中的声明: extern boolean _fastcall InNonSuspendableCriticalRegion(DWORD); 这是汇编代码中的声明: public @InNonSuspendableCriticalRegion@4 @InNonSuspendableCriticalRegion@4 proc near ; fastcall &l

我正在尝试将VisualStudio 2010 C程序调用作为fastcall约定汇编例程

这是C代码中的声明:

extern boolean _fastcall InNonSuspendableCriticalRegion(DWORD);
这是汇编代码中的声明:

      public @InNonSuspendableCriticalRegion@4

  @InNonSuspendableCriticalRegion@4 proc near ; fastcall
         <code>
  @InNonSuspendableCriticalRegion@4 endp
public @InNonSuspendableCriticalRegion@4

@InNonSuspendableCriticalRegion@4 proc near ; fastcall
     ;; code
@InNonSuspendableCriticalRegion@4 endp
我收到以下链接器错误:

   Assembling: C:\DMS\Domains\PARLANSE\Tools\RunTimeSystem\Source\PARLANSE0.asm
   1>RuntimeSupport.obj : error LNK2001: unresolved external symbol @InNonSuspendableCriticalRegion@4
我肯定我做错了什么傻事,但我看不出来

MS文档很难理解,因为它太模糊了。我记得在过去的迷雾中,汇编程序也会进行一些名称更改,所以我不确定如何进行 我提供的名字正在被弄乱,如果是的话

这是关于如何做的问题,我想我完全遵循它;上面说,

13. FASTCALL Caller and Callee Summary

The following sample illustrates the code generated in the calling function and in the called function to support __fastcall, the fastcall calling convention:

   int __fastcall FastFunc( int a, int b );

      calling function    called function
      -------------------------------------------
      mov edx, b          @FastFunc@8 PROC NEAR
      mov ecx, a                       .
      call @FastFunc@8                 .
       .                               .
       .                              RET 8
       .                  @FastFunc@8 ENDP
有什么线索吗


谢谢…

尝试在两个对象文件上运行转储站以转储符号表。应该同时显示发出的函数名和引用函数名。这通常有助于诊断此类问题。

尝试在两个对象文件上运行dumpbin以转储符号表。应该同时显示发出的函数名和引用函数名。这通常有助于诊断此类问题

这是汇编代码中的声明:

      public @InNonSuspendableCriticalRegion@4

  @InNonSuspendableCriticalRegion@4 proc near ; fastcall
         <code>
  @InNonSuspendableCriticalRegion@4 endp
public @InNonSuspendableCriticalRegion@4

@InNonSuspendableCriticalRegion@4 proc near ; fastcall
     ;; code
@InNonSuspendableCriticalRegion@4 endp
我想你很接近。这个答案中唯一真正的洞察是汇编程序在默认情况下不会损坏,因此,如果您调用您的过程
InNonSuspendableCriticalRegion
,那么它就是这样导出的。为了得到一个更高级语言的名称,你通常可以按照Alexey的建议去做。但是没有
FASTCALL
,所以只需使用
别名即可

改为这样做:

title Really cool assembly routines
public InNonSuspendableCriticalRegion

.486
.MODEL FLAT

.CODE
ALIGN   8

ALIAS <@InNonSuspendableCriticalRegion@4> = <InNonSuspendableCriticalRegion>

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

InNonSuspendableCriticalRegion proc
    ;; code
InNonSuspendableCriticalRegion endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

;; ...

end
Dumpbin

请注意,符号
MASM\u RDRAND\u GenerateBlock
是使用
External
导出的,它将使用别名
@MASM\u RDRAND>再次导出_GenerateBlock@8
并显示为
WeakExternal

如果没有线条符号(标签),请确保使用
/Zi
组装。这是MASM文件的调试信息

C:\>dumpbin /SYMBOLS rdrand-x86.obj

Dump of file rdrand-x86.obj

File Type: COFF OBJECT

COFF SYMBOL TABLE
000 00DF520D ABS    notype       Static       | @comp.id
001 00000011 ABS    notype       Static       | @feat.00
002 00000000 SECT1  notype       Static       | .text$mn
    Section length   6F, #relocs    0, #linenums    0, checksum        0
004 00000000 SECT2  notype       Static       | .data
    Section length    0, #relocs    0, #linenums    0, checksum        0
006 00000000 SECT3  notype       Static       | .debug$S
    Section length  534, #relocs   26, #linenums    0, checksum        0
008 00000000 SECT4  notype       Static       | .debug$T
    Section length   3C, #relocs    0, #linenums    0, checksum        0
00A 00000000 SECT1  notype ()    External     | MASM_RDRAND_GenerateBlock
00B 00000000 UNDEF  notype       WeakExternal | @MASM_RDRAND_GenerateBlock@8
    Default index        A Alias record
00D 00000038 SECT1  notype ()    External     | MASM_RDSEED_GenerateBlock
00E 00000038 UNDEF  notype       WeakExternal | @MASM_RDSEED_GenerateBlock@8
    Default index        D Alias record
010 00000000 SECT1  notype       Static       | $$000000
011 00000000 SECT1  notype       Label        | GenerateBlock_Top
012 00000005 SECT1  notype       Label        | Call_RDRAND_EAX
013 0000000A SECT1  notype       Label        | RDRAND_succeeded
014 0000000F SECT1  notype       Label        | Full_Machine_Word
015 00000019 SECT1  notype       Label        | Partial_Machine_Word
016 0000002A SECT1  notype       Label        | Bit_1_Not_Set
017 00000034 SECT1  notype       Label        | Bit_0_Not_Set
018 00000034 SECT1  notype       Label        | GenerateBlock_Return
019 00000038 SECT1  notype       Label        | GenerateBlock_Top
01A 0000003D SECT1  notype       Label        | Call_RDSEED_EAX
01B 00000042 SECT1  notype       Label        | RDSEED_succeeded
01C 00000047 SECT1  notype       Label        | Full_Machine_Word
01D 00000051 SECT1  notype       Label        | Partial_Machine_Word
01E 00000062 SECT1  notype       Label        | Bit_1_Not_Set
01F 0000006C SECT1  notype       Label        | Bit_0_Not_Set
020 0000006C SECT1  notype       Label        | GenerateBlock_Return
这是汇编代码中的声明:

      public @InNonSuspendableCriticalRegion@4

  @InNonSuspendableCriticalRegion@4 proc near ; fastcall
         <code>
  @InNonSuspendableCriticalRegion@4 endp
public @InNonSuspendableCriticalRegion@4

@InNonSuspendableCriticalRegion@4 proc near ; fastcall
     ;; code
@InNonSuspendableCriticalRegion@4 endp
我想你很接近。这个答案中唯一真正的洞察是汇编程序在默认情况下不会损坏,因此,如果您调用您的过程
InNonSuspendableCriticalRegion
,那么它就是这样导出的。为了得到一个更高级语言的名称,你通常可以按照Alexey的建议去做。但是没有
FASTCALL
,所以只需使用
别名即可

改为这样做:

title Really cool assembly routines
public InNonSuspendableCriticalRegion

.486
.MODEL FLAT

.CODE
ALIGN   8

ALIAS <@InNonSuspendableCriticalRegion@4> = <InNonSuspendableCriticalRegion>

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

InNonSuspendableCriticalRegion proc
    ;; code
InNonSuspendableCriticalRegion endp

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

;; ...

end
Dumpbin

请注意,符号
MASM\u RDRAND\u GenerateBlock
是使用
External
导出的,它将使用别名
@MASM\u RDRAND>再次导出_GenerateBlock@8
并显示为
WeakExternal

如果没有线条符号(标签),请确保使用
/Zi
组装。这是MASM文件的调试信息

C:\>dumpbin /SYMBOLS rdrand-x86.obj

Dump of file rdrand-x86.obj

File Type: COFF OBJECT

COFF SYMBOL TABLE
000 00DF520D ABS    notype       Static       | @comp.id
001 00000011 ABS    notype       Static       | @feat.00
002 00000000 SECT1  notype       Static       | .text$mn
    Section length   6F, #relocs    0, #linenums    0, checksum        0
004 00000000 SECT2  notype       Static       | .data
    Section length    0, #relocs    0, #linenums    0, checksum        0
006 00000000 SECT3  notype       Static       | .debug$S
    Section length  534, #relocs   26, #linenums    0, checksum        0
008 00000000 SECT4  notype       Static       | .debug$T
    Section length   3C, #relocs    0, #linenums    0, checksum        0
00A 00000000 SECT1  notype ()    External     | MASM_RDRAND_GenerateBlock
00B 00000000 UNDEF  notype       WeakExternal | @MASM_RDRAND_GenerateBlock@8
    Default index        A Alias record
00D 00000038 SECT1  notype ()    External     | MASM_RDSEED_GenerateBlock
00E 00000038 UNDEF  notype       WeakExternal | @MASM_RDSEED_GenerateBlock@8
    Default index        D Alias record
010 00000000 SECT1  notype       Static       | $$000000
011 00000000 SECT1  notype       Label        | GenerateBlock_Top
012 00000005 SECT1  notype       Label        | Call_RDRAND_EAX
013 0000000A SECT1  notype       Label        | RDRAND_succeeded
014 0000000F SECT1  notype       Label        | Full_Machine_Word
015 00000019 SECT1  notype       Label        | Partial_Machine_Word
016 0000002A SECT1  notype       Label        | Bit_1_Not_Set
017 00000034 SECT1  notype       Label        | Bit_0_Not_Set
018 00000034 SECT1  notype       Label        | GenerateBlock_Return
019 00000038 SECT1  notype       Label        | GenerateBlock_Top
01A 0000003D SECT1  notype       Label        | Call_RDSEED_EAX
01B 00000042 SECT1  notype       Label        | RDSEED_succeeded
01C 00000047 SECT1  notype       Label        | Full_Machine_Word
01D 00000051 SECT1  notype       Label        | Partial_Machine_Word
01E 00000062 SECT1  notype       Label        | Bit_1_Not_Set
01F 0000006C SECT1  notype       Label        | Bit_0_Not_Set
020 0000006C SECT1  notype       Label        | GenerateBlock_Return

C代码以剪切粘贴方式显示。你认为问题出在单曲“uu”上?好的,我对MS的约定也感到困惑,因为“_fastcall”是合法的,并且被C编译器接受。。。。我在C声明中尝试了“\uuuFastCall”。在行为上没有区别。使用额外的选项进行组装以生成映射文件如何?它应该包含实际的符号(名称)。此外,您应该能够在
PROC
指令中指定调用约定,请参阅和列表。这将产生适当的名称混乱,并允许您访问PROC的参数(当然,如果声明的话)。你认为问题出在单曲“uu”上?好的,我对MS的约定也感到困惑,因为“_fastcall”是合法的,并且被C编译器接受。。。。我在C声明中尝试了“\uuuFastCall”。在行为上没有区别。使用额外的选项进行组装以生成映射文件如何?它应该包含实际的符号(名称)。此外,您应该能够在
PROC
指令中指定调用约定,请参阅和列表。这将产生适当的名称mangling,并允许您访问PROC的参数(当然,如果已声明)。