WriteFile vs. _lwrite
-
Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.
-
Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.
0:000> u kernel32!_lwrite
kernel32!_lwrite:
7c838d93 8bff mov edi,edi
7c838d95 55 push ebp
7c838d96 8bec mov ebp,esp
7c838d98 837d1000 cmp dword ptr [ebp+0x10],0x0
7c838d9c 741f jz kernel32!_lwrite+0x21 (7c838dbd)
7c838d9e 6a00 push 0x0
7c838da0 8d4510 lea eax,[ebp+0x10]
7c838da3 50 push eax
0:000> u
kernel32!_lwrite+0x11:
7c838da4 ff7510 push dword ptr [ebp+0x10]
7c838da7 ff750c push dword ptr [ebp+0xc]
7c838daa ff7508 push dword ptr [ebp+0x8]
7c838dad e8ed81fdff call kernel32!WriteFile (7c810f9f)Pretty funny huh? I think u need to paste both code snipets. 8bc7c0ec02c0e404c0cc0680f7018827ebee
-
Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.
those low level C functions wrap the WIN API. So if you would write windows apps for the 16 bit version, some of the code would still be usable, since it's still provided. If you used the 16 bit API however chances are that the code would become invalid since those function might no longer exist. If you look in implementation of STL, CRT functions or whatever library MS has written, in the end they all call the WIN API to do the job. So basically all the libraries all wrappers around the system specific API. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
0:000> u kernel32!_lwrite
kernel32!_lwrite:
7c838d93 8bff mov edi,edi
7c838d95 55 push ebp
7c838d96 8bec mov ebp,esp
7c838d98 837d1000 cmp dword ptr [ebp+0x10],0x0
7c838d9c 741f jz kernel32!_lwrite+0x21 (7c838dbd)
7c838d9e 6a00 push 0x0
7c838da0 8d4510 lea eax,[ebp+0x10]
7c838da3 50 push eax
0:000> u
kernel32!_lwrite+0x11:
7c838da4 ff7510 push dword ptr [ebp+0x10]
7c838da7 ff750c push dword ptr [ebp+0xc]
7c838daa ff7508 push dword ptr [ebp+0x8]
7c838dad e8ed81fdff call kernel32!WriteFile (7c810f9f)Pretty funny huh? I think u need to paste both code snipets. 8bc7c0ec02c0e404c0cc0680f7018827ebee
Well, yes, that you went all the way to some disassembly :rolleyes: If you load the C run time source code and visually trace through it, you could see that all the 'standard' file IO calls typically devolve into CreateFile, ReadFile, WriteFile, and CloseHandle - after psending a fair bit of time mapping the fiol I/O flags and parameters into the ones that the Win32 API expects ;)
-
those low level C functions wrap the WIN API. So if you would write windows apps for the 16 bit version, some of the code would still be usable, since it's still provided. If you used the 16 bit API however chances are that the code would become invalid since those function might no longer exist. If you look in implementation of STL, CRT functions or whatever library MS has written, in the end they all call the WIN API to do the job. So basically all the libraries all wrappers around the system specific API. Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
Well, yes, that you went all the way to some disassembly :rolleyes: If you load the C run time source code and visually trace through it, you could see that all the 'standard' file IO calls typically devolve into CreateFile, ReadFile, WriteFile, and CloseHandle - after psending a fair bit of time mapping the fiol I/O flags and parameters into the ones that the Win32 API expects ;)
Of course they are, that was the point :) 8bc7c0ec02c0e404c0cc0680f7018827ebee
-
OOPS...i shows me as Anonymous. never mind. Once again thanks for your replies. Devoirs ____________________________________________________________ rishabhs I think therefore I am.