News:

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

Undefined symbols etc.

Started by Magnum, November 08, 2011, 01:54:36 PM

Previous topic - Next topic

Magnum

I am getting errors with this. I read the masmguide but can't figure what I am doing wrong.



GetCdHandle PROTO :DWORD
VerifyMedia PROTO :DWORD

CTEXT MACRO text:VARARG
            LOCAL TxtName
              .data
               TxtName BYTE text,0
              .code
            EXITM <ADDR TxtName>
ENDM

.const

IOCTL_STORAGE_CHECK_VERIFY  equ 002d4800h
IOCTL_STORAGE_CHECK_VERIFY2 equ 002d0800h

.data

hWnd          dd 0

.data?

hDevice     dw   ?

start:

ASSUME  FS:nothing

invoke GetCDHandle,CTEXT ("\\.\E:")
.if eax !=0

invoke VerifyMedia,hDevice

.if eax==TRUE

invoke SetDlgItemText,hWnd,1003,CTEXT ("CD Found!")

.else
invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
jmp @F

.endif

GetCDHandle  proc lpszDevice:DWORD
invoke CreateFile,lpszDevice,GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
    .if eax != INVALID_HANDLE_VALUE
        mov  hDevice,eax
    .else
        mov eax,FALSE
    .endif     
ret
GetCDHandle endp

VerifyMedia Proc _hDevice:DWORD
LOCAL dwBytes:DWORD
invoke DeviceIoControl,_hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0,0, 0, addr dwBytes, 0
.if eax!=0
         mov eax,1
.else
         mov eax,0
      .endif
    ret
VerifyMedia endp

invoke ExitProcess,0

end start


Have a great day,
                         Andy

ToutEnMasm

there is a miising information :
Quote
Setting environment for using Microsoft Visual Studio 2010 x86 tools.
Microsoft (R) Macro Assembler Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Assembling: ecrase.asm
ecrase.asm(1) : error A2119:language type must be specified
ecrase.asm(11) : error A2013:.MODEL must precede this directive
ecrase.asm(16) : error A2013:.MODEL must precede this directive
ecrase.asm(18) : error A2034:must be in segment block
ecrase.asm(20) : error A2013:.MODEL must precede this directive
ecrase.asm(22) : error A2034:must be in segment block
ecrase.asm(24) : error A2034:must be in segment block
ecrase.asm(28) : error A2013:.MODEL must precede this directive
CTEXT(2): Macro Called From
  ecrase.asm(28): Main Line Code
ecrase.asm(28) : error A2034:must be in segment block
CTEXT(3): Macro Called From
  ecrase.asm(28): Main Line Code
ecrase.asm(28) : error A2013:.MODEL must precede this directive
CTEXT(4): Macro Called From
  ecrase.asm(28): Main Line Code
ecrase.asm(28) : error A2006:undefined symbol : GetCDHandle
ecrase.asm(29) : error A2034:must be in segment block
ecrase.asm(31) : error A2006:undefined symbol : hDevice
ecrase.asm(31) : error A2114:INVOKE argument type mismatch : argument : 1
ecrase.asm(31) : error A2034:must be in segment block
ecrase.asm(33) : error A2034:must be in segment block
ecrase.asm(35) : error A2013:.MODEL must precede this directive
CTEXT(2): Macro Called From
  ecrase.asm(35): Main Line Code
ecrase.asm(35) : error A2034:must be in segment block
CTEXT(3): Macro Called From
  ecrase.asm(35): Main Line Code
ecrase.asm(35) : error A2013:.MODEL must precede this directive
CTEXT(4): Macro Called From
  ecrase.asm(35): Main Line Code
ecrase.asm(35) : error A2006:undefined symbol : SetDlgItemText
ecrase.asm(37) : error A2034:must be in segment block
ecrase.asm(38) : error A2013:.MODEL must precede this directive
CTEXT(2): Macro Called From
  ecrase.asm(38): Main Line Code
ecrase.asm(38) : error A2034:must be in segment block
CTEXT(3): Macro Called From
  ecrase.asm(38): Main Line Code
ecrase.asm(38) : error A2013:.MODEL must precede this directive
CTEXT(4): Macro Called From
  ecrase.asm(38): Main Line Code
ecrase.asm(38) : error A2006:undefined symbol : SetDlgItemText
ecrase.asm(39) : error A2034:must be in segment block
ecrase.asm(41) : error A2034:must be in segment block
ecrase.asm(43) : error A2034:must be in segment block : GetCDHandle
ecrase.asm(44) : error A2006:undefined symbol : CreateFile
ecrase.asm(45) : error A2034:must be in segment block
ecrase.asm(46) : error A2034:must be in segment block
ecrase.asm(47) : error A2034:must be in segment block
ecrase.asm(48) : error A2034:must be in segment block
ecrase.asm(49) : error A2034:must be in segment block
ecrase.asm(50) : error A2034:must be in segment block
ecrase.asm(51) : fatal error A1010:unmatched block nesting : GetCDHandle

There has been an error while assembling this project.

Appuyez sur une touche pour continuer...
miss at least three lines
Quote
   .586            
   .model flat, stdcall      ;
   option casemap :none      ;   
               

ToutEnMasm

Here a version without error at compile (surely not working)
Quote
   .586            ;
   .model flat, stdcall      ;
   option casemap :none      ;l ou majuscules               

VerifyMedia PROTO :DWORD

CTEXT MACRO text:VARARG
            LOCAL TxtName
              .data
               TxtName BYTE text,0
              .code
            EXITM <ADDR TxtName>
ENDM
   include windows.inc      ;<<<<<<<<< include files
   include kernel32.inc
   include user32.inc

.const

IOCTL_STORAGE_CHECK_VERIFY  equ 002d4800h
IOCTL_STORAGE_CHECK_VERIFY2 equ 002d0800h
GetCDHandle proto :DWORD
VerifyMedia PROTO :DWORD        ;<<<<<<<<<<<<<<<<<<<<<
.data

hWnd          dd 0

.data?

hDevice     dd   ?              ;<<<<<<<<<<<<<<<<<< DWORD not dw
.code
start:
ASSUME  FS:nothing
invoke GetCDHandle,CTEXT ("\\.\E:")
   .if eax !=0
   invoke VerifyMedia,hDevice

      .if eax==TRUE
      invoke SetDlgItemText,hWnd,1003,CTEXT ("CD Found!")
      .else
         invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
         ;jmp @F
      .endif
   .endif ;<<<<<<<<<<<<<<<<<<<<<<<<< perhps here ??????????????????????????????????
   @@: ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< perhaps here ?????????????????????
   
invoke ExitProcess,0          ; <<<<<<<<< proc are always after


GetCDHandle  proc lpszDevice:DWORD
   invoke CreateFile,lpszDevice,GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
    .if eax != INVALID_HANDLE_VALUE
        mov  hDevice,eax
    .else
        mov eax,FALSE
    .endif     
   ret
GetCDHandle endp

VerifyMedia Proc _hDevice:DWORD
LOCAL dwBytes:DWORD   
   invoke DeviceIoControl,_hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0,0, 0, addr dwBytes, 0
   .if eax!=0
         mov eax,1
   .else
         mov eax,0
      .endif
    ret
VerifyMedia endp


end start

ragdog

Hi Magnum

This code its from me or??

Magnum

It might be.


.686                                     
.model flat, stdcall                     
option casemap :none                       

include \masm32\include\windows.inc   
include \masm32\include\masm32.inc     

include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\ole32.inc
include \masm32\include\msvcrt.inc
include \masm32\include\winmm.inc
include \masm32\include\advapi32.inc

include \masm32\include\dialogs.inc   
include \masm32\macros\macros.asm     

includelib \masm32\lib\masm32.lib     

includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\ole32.lib
includelib \masm32\lib\msvcrt.lib
includelib \masm32\lib\winmm.lib
includelib \masm32\lib\advapi32.inc

GetCdHandle PROTO :DWORD
VerifyMedia PROTO :DWORD

CTEXT MACRO text:VARARG
            LOCAL TxtName
              .data
               TxtName BYTE text,0
              .code
            EXITM <ADDR TxtName>
ENDM

.const

IOCTL_STORAGE_CHECK_VERIFY  equ 002d4800h
IOCTL_STORAGE_CHECK_VERIFY2 equ 002d0800h

.data

hWnd          dd 0

.data?

hDevice     dw   ?

start:

ASSUME  FS:nothing

invoke GetCDHandle,CTEXT ("\\.\E:")
.if eax !=0

invoke VerifyMedia,hDevice

.if eax==TRUE

invoke SetDlgItemText,hWnd,1003,CTEXT ("CD Found!")

.else
invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
jmp @F

.endif

@@:

GetCDHandle  proc lpszDevice:DWORD
invoke CreateFile,lpszDevice,GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
    .if eax != INVALID_HANDLE_VALUE
        mov  hDevice,eax
    .else
        mov eax,FALSE
    .endif     
ret
GetCDHandle endp

VerifyMedia Proc _hDevice:DWORD
LOCAL dwBytes:DWORD
invoke DeviceIoControl,_hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0,0, 0, addr dwBytes, 0
.if eax!=0
         mov eax,1
.else
         mov eax,0
      .endif
    ret
VerifyMedia endp

invoke ExitProcess,0

end start


Have a great day,
                         Andy

dedndave

GetCdHandle PROTO :DWORD
GetCDHandle  proc lpszDevice:DWORD

dedndave

hDevice     dw   ?

handles are dwords, or

hDevice HANDLE ?

Magnum

This works,  but needs some more refining.


start:

invoke GetDriveType,addr Drv_Path

; 0 The drive type cannot be determined.
; 1 The root directory does not exist.
; 2 DRIVE_REMOVABLE The drive can be removed from the drive.
; 3 DRIVE_FIXED The disk cannot be removed from the drive.
; 4 DRIVE_REMOTE The drive is a remote (network) drive.
; 5 DRIVE_CDROM The drive is a CD-ROM drive.
; 6 DRIVE_RAMDISK The drive is a RAM disk.

.IF (eax==5)
       
invoke  MessageBox, NULL, addr CD_Drive, addr AppName, MB_OK


.ENDIF



invoke ExitProcess,0


end start

Have a great day,
                         Andy

dedndave

.data?

hDevice     dd   ?

start:


start has to be in a .code section

Magnum

This is what I am getting on the other code.

I don't know what is up with GetCDHandle.  :(

Assembling: C:\masm32\SOURCE\Is_CD.asm
C:\masm32\SOURCE\Is_CD.asm(61) : error A2108:use of register assumed to ERROR
C:\masm32\SOURCE\Is_CD.asm(65) : error A2006:undefined symbol : GetCDHandle
C:\masm32\SOURCE\Is_CD.asm(106) : fatal error A1010:unmatched block nesting : .if-.repeat-.while
Have a great day,
                         Andy

dedndave

you have an open .if/.endif block
invoke GetCDHandle,CTEXT ("\\.\E:")
.if eax !=0

invoke VerifyMedia,hDevice

.if eax==TRUE

invoke SetDlgItemText,hWnd,1003,CTEXT ("CD Found!")

.else
invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
jmp @F

.endif

dedndave


Magnum

Thanks Dave.

I feel like an idiot for forgetting about .code.

Down to 2 error messages.

C:\masm32\SOURCE\Is_CD.asm(67) : error A2006:undefined symbol : GetCDHandle
C:\masm32\SOURCE\Is_CD.asm(108) : fatal error A1010:unmatched block nesting : .if-.repeat-.while
Have a great day,
                         Andy

dedndave

i made 4 changes and got it to assemble
all listed above

Magnum

It assembles.

Is this supposed to show anything on the screen ?

invoke SetDlgItemText,hWnd,1003,CTEXT ("No CD Found!")
Have a great day,
                         Andy