News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

i need help, MASM32 & Delphi (use .OBJ files)

Started by Dasar, August 28, 2006, 01:20:51 PM

Previous topic - Next topic

Dasar

hi all

could any one tell me  how to use the functions which i write in masm32 in a delphi program..

yes, i know that there is a way using the .OBJ files, and using the directive {$L} in Delphi...

{$L} directive is used to link Functions in OBJ files that are written in an other programming languages..

but delphi help said: that the function in these OBJ files must be declared to be external !!

i don't know how to declare my function to be external in masm32  :(

any help is very appreciated, and thanks in advance.  ^_^

hutch--

I cannot help you with Delphi but is worth you finding out what type of object module Delphi uses. MASM in 32 bit usually uses COFF format object modules but vaguely I remember that Borland stuff used OMF which MASM will build if you set the correct option on the command line.

Somewhere along the line the Delphi compiler must know the details of the object module you write in masm so you probably need to write a prototype for it in Delphi code. Perhaps one of the Borland guys if there are any left may be able to help you better.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

drizz

MASM
ml /nologo /c /omf Something.asm
OMF2D by EliCZ - http://www.anticracking.sk/EliCZ/export.htm
omf2d Something.obj Something.obj
DELPHI
{$L Something.obj}
The truth cannot be learned ... it can only be recognized.

Dasar

hutch thank you very much for your help.

drizz, thank you for the info, i'll test and tell you :)

drizz

no need to report back, i know it works :lol
only i am not much of a talker :)
The truth cannot be learned ... it can only be recognized.

Dasar

hi drizz

i did what you said exactly, and its works fine, but i have a problem, i always get this message in the assembler:

MASM : warning A4018: invalid command-line option : /omf
MASM : fatal error A1017: missing source filename



i used this line to assemble  ( i use masm32 V 9 )  :

ml /nologo /c /omf GiveMePath.asm

and this is my code:  ( just a simple function )


.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib


GiveMePath PROTO STDCALL :DWORD, :DWORD

.data
  tFullpath db "c:\someFolder\SomeFolderNumber2\andThisIs3\AnyFile.exe",0

.data?
  tPath db MAX_PATH dup(?)

.code

  GiveMePath proc FullPath: DWORD, Path: DWORD
  push esi
  push edi
  mov eax, FullPath
  @@:
  mov cl, BYTE PTR [eax]
  inc eax
  cmp cl, 0
  jne @B
  dec eax
  @@:
  mov cl, BYTE PTR [eax]
  dec eax
  cmp cl, '\'
  jne @B
  inc eax
  mov esi, FullPath
  mov edi, Path
  xor edx, edx

  sub eax, esi
       
  inc eax   
                     
  @@:
  mov cl, BYTE PTR [esi + edx]
  mov BYTE PTR [edi + edx], cl
  inc edx
  cmp eax, edx
  jne @B
  mov eax, edx
  pop edi
  pop esi
  ret
  GiveMePath ENDP

start:

invoke GiveMePath, Addr tFullpath, Addr tPath
invoke MessageBox, 0, Addr tPath, Addr tPath, MB_OK
invoke ExitProcess, 0

end start



what's wrong here ??

btw: the function is works fine, in assembly, and in delphi when i link the final OBJ file, but i don't know why i get the error message ( invalid command-line option : /omf ) !!!!

thanks in advance ^_^

drizz

i'm using ML v6.15 for a long time...,
the ml v6.14 produces omf objects by default,
but for ML >= 6.15 you need the /omf switch

so just remove it...

BTW, all you need in your asm file is this:

.386
.model flat, stdcall
option casemap:none

.code
  GiveMePath proc FullPath: DWORD, Path: DWORD
  push esi
  push edi
  mov eax, FullPath
  @@:
  mov cl, BYTE PTR [eax]
  inc eax
  cmp cl, 0
  jne @B
  dec eax
  @@:
  mov cl, BYTE PTR [eax]
  dec eax
  cmp cl, '\'
  jne @B
  inc eax
  mov esi, FullPath
  mov edi, Path
  xor edx, edx

  sub eax, esi
       
  inc eax   
                     
  @@:
  mov cl, BYTE PTR [esi + edx]
  mov BYTE PTR [edi + edx], cl
  inc edx
  cmp eax, edx
  jne @B
  mov eax, edx
  pop edi
  pop esi
  ret
  GiveMePath ENDP
end
The truth cannot be learned ... it can only be recognized.

Vortex

Dasar,

Hutch's masm32.lib provides path functions, check masmlib.hlp for the details. The functions are listed below :

GetAppPath :

GetAppPath returns the address of the running application's path as a zero terminated string
with the filename removed. The last character in the string is a trailing backslash "\" to
facilitate parsing different filenames to the path.

NameFromPath :

NameFromPath reads the filename from a complete path and returns it in the buffer specified
in the parameter list.

GetPathOnly :

GetPathOnly reads the path of a complete file path and returns the path portion in the
destination buffer.

Dasar

Vortex  thanks for the reply, but i just write that as an example :)