0

im trying to make a lib in masm32 (using radasm) for use in other projects...

the libs source code :

.386
.MODEL flat,stdcall
option casemap:none
.code
start:
PUBLIC HookProc
HookProc proc addy:DWORD

and for use in msvc :

extern "C" void* HookProc(void* ptr);
#pragma comment(lib, "TestHook.lib")

however this produces an error :

Win32Project1.obj : error LNK2019: unresolved external symbol _HookProc referenced in function _wmain

but i see in the lib there is

!<arch>
/               1368690603              0       20        `
®_HookProc@4/               1368690603              0       26        `

Why cant msvc see this proc in the lib ?? ;/ does this have something to do with the @4 ?

Edit : changed to .MODEL flat, c that got rid of @4 , but still _HookProc uresolved......

n00b
  • 5,642
  • 2
  • 30
  • 48
  • Can you show the assmebly file? Not neccessarily the whole function, just the declarations would suffice. I provided a small sample which I tested and works. – Devolus May 16 '13 at 09:09

1 Answers1

1

CPP:

extern "C" int GetValue(void);

int main(int argc, char*arg[])
{
    char *p = "test";
    int v = GetValue();

    return 0;
}

ASM:

.486
.model flat, C
option casemap :none

.code

GetValue PROC
    mov eax, 1234
    ret
GetValue ENDP

END
Devolus
  • 21,661
  • 13
  • 66
  • 113
  • actually it works with `.model flat, c` so my fail was calling conventions. – n00b May 16 '13 at 09:16
  • 1
    Well it was a nice exercise for me to get back into this assembly stuff. I had to google for examples because I ran into the same problem. :) – Devolus May 16 '13 at 09:42