HELP!
Hi, I'm trying to link an assembly procedure to my C++ project, I'm using Visual C++ 2005.
I'm getting an error:
DecodeB64.obj : error LNK2019: unresolved external symbol _Base64_Decode referenced in function _main
I added both the .asm and the .cpp files to my project.
In my cpp file:
Code:
#define DWORD unsigned int
extern "C" DWORD Base64_Decode(char *, DWORD, char *);
and in main:
Code:
dwDataLen = Base64_Decode(cpInputBuffer, dwFileSize, cpOutputBuffer);
my .asm file:
Code:
public _Base64_Decode
.386
.MODEL flat, stdcall
.CODE
_Base64_Decode proc
local InputLen : dword
local InputBuf : dword
local OutputBuf : dword
pop InputBuf
pop InputLen
pop OutputBuf
pushad
mov ecx,InputLen
mov esi,InputBuf
ASCII_TO_B64_LOOP:
mov ah,[esi]
cmp ah,61h ;compare to 'a'
jl CMP_CAPS
sub ah,47h
jmp NEXT
CMP_CAPS:
cmp ah,41h ;compare to 'A'
jl CMP_PAD
sub ah,41h
jmp NEXT
CMP_PAD:
cmp ah,3D ;compare to '='
jne CMP_NUMERAL
mov ah,0h
jmp NEXT
CMP_NUMERAL:
cmp ah,30h ;compare to '0'
jl SYMBOL
add ah,4h
jmp NEXT
SYMBOL:
cmp ah,2Fh ;compare to '/'
jl PLUS
mov ah,3Fh
jmp NEXT
PLUS: ;it's '+'
mov ah,3Eh
jmp NEXT
NEXT:
inc esi
loopw ASCII_TO_B64_LOOP
mov edi,OutputBuf
mov esi,InputBuf
mov ecx,InputLen
xor edx,edx
mov eax,4h
div ecx
mov ecx,eax
DECODING_LOOP:
mov ah,[esi]
mov al,[esi+1]
shl al,2
mov bl,ah
mov dh,al
shld bx,dx,2
mov ah,bl
mov [edi],ah
inc edi
inc esi
mov ah,[esi]
mov al,[esi+1]
shl al,2
mov bl,ah
mov dh,al
shld bx,dx,4
mov ah,bl
mov [edi],ah
inc edi
inc esi
mov ah,[esi]
mov al,[esi+1]
shl al,2
mov bl,ah
mov dh,al
shld bx,dx,6
mov ah,bl
mov [edi],ah
inc edi
inc esi
inc esi
loopd DECODING_LOOP
popad
mov dx,0h
mov ax,sizeof OutputBuf
ret
_Base64_Decode endp
end