flat assembler
Message board for the users of flat assembler.

Index > Windows > import from kernel32.dll

Author
Thread Post new topic Reply to topic
mindflyr



Joined: 19 Feb 2005
Posts: 6
Location: New Hampshire, USA
mindflyr 23 Feb 2005, 00:58
I want to use the WriteFile function from kernel32.dll in windows\system32\.
In example DDRAW, I found this import excerpt:
CreateFile,'CreateFileA',\
ReadFile,'ReadFile',\
I noticed the A after CreateFile, and so I grep'd in the dll and also noticed
CreatedFileW, I think. The help file provided by FASM didn't seem to have
exactly what to do.

I could just guess to code: WriteFile,'WriteFile',\ in the import section.
Anyone know???? Confused

_________________
Alison Krauss fan.
Post 23 Feb 2005, 00:58
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 23 Feb 2005, 02:07
The most functions in Win32 API exists in two variants: ANSI (or ASCII) with suffix "A" and WIDE (or UNICODE) with suffix 'W' - that are mostly the fuctions that deal (even indirectly) with strings. Usually in one application it is very rare case to be used both - ASCII and UNICODE function, so it is common practice to be imported only one of them (and probably it will be ASCII function).
You can notice also, that in FASM package, there are two sets of include files - W and A.
For your case, I would suggest you to use A variant.
As far as, these functions do the same thing, only with difference in string formats, in help files you can read only one description of the function.

AFAIK, in WinNT/2000/XP, there is only one UNICODE function and the "A" function simply converts ASCII strings to UNICODE format and pass them to the original UNICODE function. In Win95/98/ME convertion is reversed - the main function is ASCII and the "W" function make convertion and calls "A" function.

Regards.
Post 23 Feb 2005, 02:07
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
mindflyr



Joined: 19 Feb 2005
Posts: 6
Location: New Hampshire, USA
mindflyr 23 Feb 2005, 18:25
Thank you JohnFound. So far I successfully read and wrote a small binary file with the following. I'll try the 'A' after ReadFile and WriteFile soon.
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
...
import kernel,\
...
CreateFile,'CreateFileA',\
ReadFile,'ReadFile',\
WriteFile,'WriteFile',\
CloseHandle,'CloseHandle',\
ExitProcess,'ExitProcess'
Post 23 Feb 2005, 18:25
View user's profile Send private message Reply with quote
mindflyr



Joined: 19 Feb 2005
Posts: 6
Location: New Hampshire, USA
mindflyr 24 Feb 2005, 19:05
ReadFileA and W say "no entry point found in dll".
Same for WriteFileA and W.
And also I tried CreateFileW, but it crashed, probably because I should have a different kind of string for the pathname of the read_filename.
But everything works great with CreateFileA and ReadFile and WriteFile.
Post 24 Feb 2005, 19:05
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 24 Feb 2005, 19:49
Well, ReadFile is not a function that deals with strings, so there is no need to exists in 2 variants.

Better check and use existing import files in FASM include/APIA or include/APIW directories. It is simply waste of time to build your own import sections.

Regards.
Post 24 Feb 2005, 19:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.