zoukankan      html  css  js  c++  java
  • nasm astrlen函数 x86

    xxx.asm

    %define p1 ebp+8
    %define p2 ebp+12
    %define p3 ebp+16
    
    section .text
      global dllmain
      export astrlen
    
    dllmain:
      mov eax,1
      ret 12
    
    astrlen:
      push ebp
      mov ebp,esp
    
      mov ecx,[p1]  	 ; char ptr
      xor eax,eax
    
      .for:
      cmp byte [ecx],0
      je .return
    
      inc ecx
      inc eax
      jmp .for
    
      .return:
      mov esp,ebp
      pop ebp
      ret 4
    

    link.fil:

    /entry dllmain
    /dll
    
    xxx.obj
    

    c++

    #include <iostream>
    #include <Windows.h>
    
    typedef int (CALLBACK* astrlen_t)(const char*);
    
    astrlen_t astrlen;
    
    int main()
    {
      HMODULE myDLL = LoadLibraryA("xxx.dll");
      astrlen = (astrlen_t)GetProcAddress(myDLL, "astrlen");
      
      printf("%d
    ", astrlen("hello world")); // 11
      printf("%d
    ", astrlen("nasm")); // 4
    
      return 0;
    }
    
  • 相关阅读:
    python3第六天
    python3第五天
    python3第四天
    python3 第三天
    python3第二天
    python3(2)
    python3(1)
    网络通信 & 初识socket
    python中包的语法
    模块语法
  • 原文地址:https://www.cnblogs.com/ajanuw/p/13719952.html
Copyright © 2011-2022 走看看