아날로그 DLL 로드

4710 단어 dll
#include <stdio.h>

#include <malloc.h>

#include <sys/stat.h>

typedef int (*PFUNC)(int,int);

typedef struct

{

    int Position;

    int Length;

}Fun;



typedef struct

{

    int num;

    Fun *pFun;

}Lib;



int main()

{

 

    int FileSize =0;

    char FileName[] = "code.obj";

    FILE * FileHandle = fopen(FileName,"rb");

    if(FileHandle!=NULL)

    {

        Lib lib;

        fread(&lib.num,sizeof(char),4,FileHandle);

        //          

        lib.pFun =(Fun*)malloc(sizeof(Fun)*lib.num);

        fread(lib.pFun,sizeof(Fun),lib.num,FileHandle);

        //             ,(     )     

        char *instruction= (char*)malloc(sizeof(char)*lib.pFun->Length);

        //               

        fseek(FileHandle,lib.pFun->Position,0);

        //       ,      ,0         

        fread(instruction,sizeof(char),lib.pFun->Length,FileHandle);

        //           

        PFUNC pfunc = (PFUNC)instruction;

        printf("%d 
",pfunc(3,4)); // } } /* : 1) , , DLL 2) char A[m], char , , A[0], , A[0], 10 , , A[10], , fseek size_t fread(void *buffer,size_t size,size_t count,FILE *stream) { int i=0; while(stream->ptr!=NULL && i<count) { buffer = stream->ptr; (stream->ptr)++; } return i; } // int fseek( FILE *stream,long offset,int origin) { stream->ptr = offset + origin } */

CODE.OBJ01 00 00 00 0C 00 00 00 2B 00 00 00 55 8B EC 81EC C0 00 00 00 53 56 57 8D BD 40 FF FF FF B9 3000 00 00 B8 CC CC CC CC F3 AB 8B 45 08 03 45 0C5F 5E 5B 8B E5 5D C3

좋은 웹페이지 즐겨찾기