在“ opcode”中获取错误内联汇编器语法错误;发现“恒定”

时间:2018-06-23 23:10:20

标签: c++ assembly x86 intel

我有一个简单的代码,它无缘无故地给了我一个编译器错误

  

'opcode'中的内联汇编语法错误;发现“恒定”

DWORD connectFunctionAddressReturn = 0x775368F7;

int __cdecl ws2_32_connect_hook_output(SOCKET s, const struct sockaddr *name, int namelen) {
    struct sockaddr_in *in = (struct sockaddr_in *)connect_name;
    printf("Attempting connect %d.%d.%d.%d : %d\n", in->sin_addr.S_un.S_un_b.s_b1, in->sin_addr.S_un.S_un_b.s_b2, in->sin_addr.S_un.S_un_b.s_b3, in->sin_addr.S_un.S_un_b.s_b4, htons(in->sin_port));
}


void __declspec(naked) ws2_32_connect_hook(void) { //ws2_32.connect = 775368F5

    __asm {
        PUSHAD //To be in safe environment
        PUSHFD //To be safe environment

        PUSH 0x10
        PUSH DWORD PTR SS:[EBP+0x8]
        PUSH DWORD PTR DS:[ESI+0x14]
        CALL DWORD PTR ws2_32_connect_hook_output  //<-- ERROR HERE
        ADD ESP, 0xC //clean __cdecl,4,8,C

        POPFD //Finish being in safe environment
        POPAD //Finish being in safe environment
        JMP connectFunctionAddressReturn // <-- ERROR HERE
    }
}

1 个答案:

答案 0 :(得分:0)

解决了它,我定义了CALL AND JMP,因此它在ASM代码中出错。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-mysql-data</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.3.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
<!--PART ADDED TO SOLVE THE PROBLEM -->
        <!-- JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) -->
        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.3.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>5.2.3.Final</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- Use MySQL Connector-J -->

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>