Log in

View Full Version : help with asm source


LowF
March 17th, 2003, 05:52
not sure really where to post this thread!


got asm file i managed to cut and past together *lol*, and it's real mess but need help with it, got problem with writefile function, btw it's tasm source, don't want any masm or nasm source, anyone feel they skilled on asm coding, then if u can contact me on icq 595219, and i send file , really just want it to work!

squidge
March 17th, 2003, 08:40
hxxp://win32asmboard.cjb.net/ ?

ZaiRoN
March 17th, 2003, 15:18
Hi LowF,
which is exactly your problem with WriteFile? The function fails? Have you got problem to compile the file? Or something else...

Btw, this is the syntax of the function:

BOOL WriteFile(
HANDLE hFile, // handle to file to write to
LPCVOID lpBuffer, // pointer to data to write to file
DWORD nNumberOfBytesToWrite, // number of bytes to write
LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written
LPOVERLAPPED lpOverlapped // pointer to structure needed for overlapped I/O
);

Important: the file must be created with GENERIC_WRITE flag.

I don't use tasm anymore but if I remember correctly you need to include the function using the Extrn keyword:

Extrn WriteFile:Proc

Now, you can call the function.
This is a simple example:

...
text_to_write db "example!",0
bytes_written dd 0
...
call WriteFile, handle_file, offset text_to_write, 8, offset bytes_written, 0

Hope it helps you...

Regards,
ZaiRoN

NervGaz
March 17th, 2003, 16:17
zairon: the code is correct but you have to add stdcall to the model declaration... if you don't you have to push everything for your self

Code:

push 0
push offset bytes_written
push 8
push offset text_to_write
push handle_file
call WriteFile

for the example

ZaiRoN
March 17th, 2003, 17:10
Hi NervGaz,
you are right, I was taking it for granted