Hello,

i will create a blank file and use the winapi "CreateFile" with follow code:



.386P
Locals
jumps
.Model Flat ,StdCall

Include C:\tasm\INCLUDE\W32.INC


extrn ExitProcess : PROC
extrn CreateFile : PROC


.Data
lpName db "test.txt"


.Code
Main:
CALL CreateFile,offset lpName,GENERIC_READ,FILE_SHARE_READWRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
CALL ExitProcess, 0
End Main



It produce erros:

============ ERROR ============

C:\tasm>win32 CreateFile
Turbo Assembler Version 5.0 Copyright (c) 1988, 1996 Borland International

Assembling file: CreateFile.ASM
**Error** C:\tasm\INCLUDE\W32.INC(33) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(1791) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(1846) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(2290) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(2694) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(2835) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(2883) Illegal forward reference: UNICODE
**Error** C:\tasm\INCLUDE\W32.INC(4298) PROCDESC(2) Symbol already different kind: ExitProcess
**Error** C:\tasm\INCLUDE\W32.INC(4347) PROCDESC(2) Symbol Already different kind: CreateFileA
Error messages: 9
Warning messages: None
Passes: 1

Turbo Link Version 1.6.71.0 Copyright (c) 1993,1996 Borland International
Fatal: Unable to open file 'CreateFile.obj'
===============================

mmh where is the error in my code?
Posted on 2004-09-14 03:35:55 by cre
Well first of all most guys around here code with MASM, not TASM as you use it. :o You can download MASM32 package at www.movsd.com :wink:
Dominik
Posted on 2004-09-14 05:29:07 by Dom
Here's a link to a tasm ideal windows include file.
http://www.mujweb.cz/www/komsbomb/dev/win32ti.zip
Posted on 2004-09-14 09:29:59 by Odyssey
This one works:


.386
.model flat ,stdcall

GENERIC_WRITE equ 40000000h
FILE_SHARE_WRITE equ 2h
CREATE_ALWAYS equ 2
FILE_ATTRIBUTE_NORMAL equ 80h

extrn CreateFileA:proc
CreateFile equ <CreateFileA>
extrn ExitProcess:proc

.data
lpName db "test.txt",0

.code
start:
call CreateFile,OFFSET lpName,\
GENERIC_WRITE,\
FILE_SHARE_WRITE,\
0,\
CREATE_ALWAYS,\
FILE_ATTRIBUTE_NORMAL,\
0
call ExitProcess,0
END start


Building the executable:


tasm32 /ml Createfile.asm
ilink32 Createfile.obj,,,kernel32.lib
Posted on 2004-09-14 15:20:07 by Vortex