ReadFile & WriteFile Problem?

I need to read/write on raw disk drive and it works.
After many trials, I found a little bit strange thing.
The API ReadFile and WriteFlle read/write datas only from sector size
boundaries.
I don't know why it should do like that.
Following is my code.

void readBytes ( void *readBuf, long bytesToMove, long bytesToRead)
{
	int ret = SetFilePointer (diskHandle, bytesToMove, NULL, FILE_BEGIN);

	unsigned long bytesRead;
	BOOL result = ReadFile ( diskHandle, readBuf, bytesToRead, &bytesRead
, NULL);

	printf("read %d bytes!!\n", bytesRead);
}




When

char readBuf[512];
long bytesToMove = 500
long bytesToRead = 512

It works but it read first sector, offset 0 - 512.

But I want it to read exactly from offset 500 to 1012.


I spend much time for finding a solution the problem. (Actually it is
not a problem, but it is the problem just for me)
However I could not find an adequate solution.


Thank you for any comment!!


Best Regards




Gandhar
0
gandhar (2)
7/10/2003 7:18:48 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
470 Views

Similar Articles

[PageSpeed] 8

ReadFile() and SetFilePointer() work on files, wherever they happen to
reside, as opposed to absolute disk reads.  Whether or not you'll able to do
this depends on the OS.  I use Windows 2000 exclusively so the HAL would
prohibit me from reading directly from the disk.

If I'm way off then perhaps you could better explain the problem.

"Gandhar" <gandhar@intizen.com> wrote in message
news:f5aab6e5.0307092318.5ecce236@posting.google.com...
> I need to read/write on raw disk drive and it works.
> After many trials, I found a little bit strange thing.
> The API ReadFile and WriteFlle read/write datas only from sector size
> boundaries.
> I don't know why it should do like that.
> Following is my code.
>
> void readBytes ( void *readBuf, long bytesToMove, long bytesToRead)
> {
> int ret = SetFilePointer (diskHandle, bytesToMove, NULL, FILE_BEGIN);
>
> unsigned long bytesRead;
> BOOL result = ReadFile ( diskHandle, readBuf, bytesToRead, &bytesRead
> , NULL);
>
> printf("read %d bytes!!\n", bytesRead);
> }
>
>
>
>
> When
>
> char readBuf[512];
> long bytesToMove = 500
> long bytesToRead = 512
>
> It works but it read first sector, offset 0 - 512.
>
> But I want it to read exactly from offset 500 to 1012.
>
>
> I spend much time for finding a solution the problem. (Actually it is
> not a problem, but it is the problem just for me)
> However I could not find an adequate solution.
>
>
> Thank you for any comment!!
>
>
> Best Regards
>
>
>
>
> Gandhar


0
7/10/2003 1:06:07 PM
Reply:

Similar Artilces:

Outlook 2007 rules problem? CC problem?
Okay, I'm relatively new to Outlook 2007 or Outlook in general, but I've been asked to solve a problem because they think I know what I'm doing.... :-) I installed 2007 on this computer recently and one of our know-it-all people reconfigured it for me somehow. The computer was set up so that it would receive emails from 2 different email accounts (user 1 & 2). Problem is, when an email is sent to user 1 and cc'd to user 2, user 1 gets two copies of the email and user 2 receives none. This is done with no rules applied. Now, Mr. know-it-all created a rule that would se...

problems after converting from 97 to 2003
i was using a great program someone once built for me in access 97. eversince i upgraded to office 2003 and converted the program to access 2003 and the database also my reports are not working. i need help! is there maybe something i can download that will convert from 97 to 2003 in a better way? Sorry, but "not working" doesn't give us much to go by. Are you getting any error messages? If so, what are they? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "???" <@discussions.microsoft.com> wrote in message news:A2FD1B4A...

Formatting Problem #2
I have a workbook with 9 worksheets. All but one of them are used to track different company projects, one is used for summary: various counts and sums. On the summary sheets, the individual project are separated by two blank rows. The summary data was formatted with borders. I need to remove the borders, which is easy to do. The problem is that when all the borders are removed, vertical "lines" remain that span many rows, between several columns. Removed gridlines, with no effect. These are not drawn objects. Does anyone have an idea how to remove this? Thanks Dudley Could th...

Problem with font
Everytime I create a new email and start typing a message for some reason the font has set its self to white and you can't see what u are typing, you can manually change the font back to black but when you create a new email again for some reason it has changed back to the white font, how do you fix this so once again I will automatically have black text when starting a new email, I am using outlook 2003. Are you using Word as the mail editor? Did you set a theme in Word for new items? Did you change your Windows fonts? --� Milly Staples [MVP - Outlook] Post all replies to the grou...

Problem with Data Types
hi to all I am writing a function whose parameters are the form that is active when the function is called (frmFROM), and the form that the function then opens (frmTO). My problem is that the frmTO is used as a string in line 5 and 8, but as a form in line 6. Whichever way I Dim frmTO, I get a crash. How can reslove this problem? 1 Function ReturnToMenu(frmFROM As Form, frmTO As String) 2 frmFROM.Visible = False 3 Dim prj As Object 4 Set prj = Application.CurrentProject 5 If prj.AllForms(frmTO).IsLoaded Then 6 Forms!frmTO.Visible = True 7 Else 8 ...

Exchange 2003 domain delivery problem
We have exchange running on Small Business 2003 and have a delivery problem. We are not using Exchange as a mail server so much as a intermediary between another mail server (Postfix). We have POP3 Server Service setup and that is working great on the 2003 Server. When we send through to any other domain but the one specified in the SMTP Address i.e. domain.com it works fine. When we send however to user@domain.com through Outlook via the Exchange Server we get a 5.1.1 error that it can not find the user. The user is valid on the Linux (Postfix) Mail Server for user@domain.com b...

Alignment problem with spreadsheet
I am using 97 Excel and WinXP Pro SP3. When spreadsheets (xlsx) are open, they are normally open from the left edge. But one spreadsheet opens close to the left edge (about 3 inches from the left edge; aligning the font box in toolbar). How can I move the spreadsheet to the left edge? Jorge Re-size and Save? If re-size is not avilable perhaps the workbook is protected. Unprotect to manipulate. Gord Dibben MS Excel MVP On Fri, 18 Sep 2009 10:41:47 -0600, "Jorge Cervantes" <machocraig@hotmail.com> wrote: >I am using 97 Excel and WinXP Pro SP3. >When spreadshee...

There is a problem with this website's security certificate
Hello, I bought an SSL certificate for my server (Windows Server 2003, IIS 6.0). Server included already a web site with SSL certificate, so I created a 2nd web site with different IP and different SSL certificate and different application pool that is running. When I try to access the 2nd web site I get a message from IE "There is a problem with this website's security certificate." If I click on option "Continue to this website (not recommended)", I get error "service unavailable" What could be the problem ? 1st web site is running without ...

Sent item problem,
This is a weird problem from my behalf, when i send an e-mial no matter to who, the e-mail does not go to the sent items folder. is there a certain size for a folder in outlook. Can anyone help out,thank you. Marcel. p.s.(this is outlook 98) Goto tools/options click on the Preferences tab and then email options and make sure the option to save messages in the sent folder is checked. "Marss" <marcel.rocha@tembec.com> wrote in message news:ez5El#oYDHA.1056@TK2MSFTNGP10.phx.gbl... > This is a weird problem from my behalf, when i send an e-mial no matter to > who, the e-...

New User, having problems with DLookup
First of all, this is the first time I have tried using Access, let alone trying to build a database from scratch, so if I've made a ton of mistakes, please bear with me. I am attempting to build a database to calculate allowed vacation and personal time, as well as track it automatically rather than me doing it manually. The intended end result is a database that can be used year after year by only changing a couple of fields. At the moment I am stuck on getting it to calculate allowed vacation. The string I used to test my syntax - that failed miserably - is: DLookup ( [FT V...

azerty keyboard problem
I only have the French (Canada) language installed together with the Canadian Multilingual Standard keyboard on five of my computers, but when I try to type an email adress in a new contact, the keyboard layout switches to azerty. This problem only occurs in outlook ? Thank's for your help. Christian Perreault cp(remove)@mnfo.net Change your default keyboard layout or remove the azerty layout in Control Panel-> Regional and Language Options -- Robert Sparnaaij [MVP-Outlook] www.howto-outlook.com Tips of the month: -What do the Outlook Icons Mean? -Create an Office 2003 CD slip...

Calling ReadFile after DeviceIOControl (Unexpected Results)
Hi folks, I'm using "LPT1" via CreateFile for Overlapped communications. I use WaitSingleObject and then GetOverlapped Result to collect ReadFile results. All that code, including overlapped WriteFile's work great and have been for years. However, now I need to get the BUSY state of the port. It appears the only way to do this in the context of Win32 is via: DeviceIOControl(Handle, IOCTL_PAR_QUERY_INFORMATION, Nil, 0, @status, SizeOf(status), @OVERLAPPED); This call works great, repeated adnausem and yields the proper results every time, in realtime....

Email sending problems
I use Outlook to send emails through hotmail.com to my customers. I have been experiencing, lately, a number of emails that are sent and not received by my customer. These emails show being sent and I do not get a message back that they were not delivered or were rejected for some reason. Please explain Customers are blocking mail from hotmail .com? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google....

Problem with the RichEdit control
I'm using Vusual C++ 6.0 and if I add a RichEdit control to my dialogbased application the result always is that the program immidiately exits after start. Why? You need to call AfxInitRichEdit() in your application's InitInstance() method. Vaclav "JanF" <JanF@discussions.microsoft.com> wrote in message news:FD6DFE74-81F4-47AC-B5BA-394FFA3A5103@microsoft.com... > I'm using Vusual C++ 6.0 and if I add a RichEdit control to my dialogbased > application the result always is that the program immidiately exits after > start. > Why? ...

Offline Folder problems
Dear All, I have a user who has a laptop and VPN's into a Windows 2000 domain. he like to synchronise his laptop on a regular basis so that he can work offline. His offline folders chalk up to about 900 mb which i know is a lot. basically, when he syncs now, he can see his folders structures in Outlook, but not any emails, contacts, tasks etc etc. Anyone got any ideas? Best regards, Andy ...

WLM sending problem
I have set up 2 email accounts on Windows Live Mail on a new netbook running Windows 7 Starter. The default account (mine) works fine. The other account (my wife's) receives fine but will not send. The error message ID is 0x800CCC0D. The server is smtp@ultrasw.com. That same server works for my email. Protocol is SMTP; Port 25; Secure (SSL) No; Socket error 11003. TIA for any help you can give. If I have missed a posted solution to this, I apologise. Don Eagle This is a multi-part message in MIME format. ------=_NextPart_000_004D_01CAE0C6.8D00D970 Content-Typ...

stream problems
Hi all! I am writing a little server application. This little stuff can log everything into a file. I use an ofstream to do this. So I tested it and everything was just fine. Then I decided to use this as a Windows service. So I do some little modification (based on this: http://www.codeguru.com/cpp/w-p/system/ntservices/article.php/c5749/ , originalliy it was a dialog based application.) The service runs and do what it shall (make an open port and accept connections). The problem is the that it simply "invalidate" the stream what I use. It simply not write anything into it. To ma...

Problem: Excel divides all my entries
Hi All, First my Excel 2003 was functioning perfectly, but now when I enter e.g. 1, Excel automatically divides it by 10 and shows 0.1. I'm aware that this is a cryptic descritpion, but it might be something someone is familiar with. Thanks! Sieto Hi Sieto try tools / options / edit and untick fixed decimal places if it is checked. -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "Sieto Verver" <sieto.verver@wur.nl> wrote in message news:426fa97c$1@news.wau.nl... > Hi All, > First my Excel 2003 was functioni...

mail merge problem #6
While running my newsletter with Mail Merge, I received the following message: ERROR: limitcheck OFFENDING COMMAND: image OPERAND STACK: OutputProfile r resource/OutputProfile/sharp.icm sharp.icm --no string value-- HELP! I think this is a postscript error, from the way it sounds it could be your images are simply too large. http://www.prepressure.com/ps/dbase/limitcheck.htm This from http://dspace.dial.pipex.com/quite/errors.htm#index limitcheck The printer has reached an internal limit. Some limits are fixed, some depend on memory. In level 2, there are fewer fixed limits. Most common...

"ERROR_INVALID_PARAMETER": ReadFile() and WriteFile()
I am writing a program that connects to a serial port and writes data. I follow the guides from MSDN and I use ReadFile() and WriteFile() to do data I/O. The port is opened in non-overlapped I/O mode. But whenever I call ReadFile() or WriteFile(), it returns error number 87, and when I look that up, it is the ERROR_INVALID_PARAMETER. So I made sure that everything was okay. The buffer I pass to those functions is actually allocated and okay, and the variables for how many bytes to read/write, and the lpdword for how bytes were actually read/written are okay as well. And the over...

CRM Mobile First Time registration problems
Well, I've tried everything in the troubleshooting guide3, and everything I can find on the forums/groups, but still no luck. I am trying to get CRM Mobile running for internal connection, installing on the CRM server itself. I have temporarily disabled certs and SSL, to allow for troubleshooting, and I also have a traffic tracer running. When I run CRM Mobile, it simply hangs while registering the device- it will sit there for 45 minutes, if I let it. When monitoring the traffic, I have seen that it successfully calls the /ssCERDA/ sqlcesa30.dll twice, and then it goes on to /CRMMobil...

Problem using '=' with System.Type
Hi I have the following code; ByVal MyType As Type Dim frame As StackFrame If frame.GetMethod().DeclaringType = MyType Then Problem is I am getting the "Operator '=' is not defined for types 'System.Type' and 'System.Type'." error on the last line. How can I fix this? Thanks Regards Am 23.03.2010 02:27, schrieb John: > Hi > > I have the following code; > > ByVal MyType As Type > Dim frame As StackFrame > If frame.GetMethod().DeclaringType = MyType Then > > Problem is I am getting the "Ope...

CToolTipCtrl problem
Hello, I need help, I'm trying use tool tip in list control, the problem is that tip must be changed for each item. How to do this? After tip is showed there is no other notifications from control when mouse was moved over another item in list control Thank you If you want to change the text, while the tooltip is displayed, you can use SetWindowText to change it.That means you will need to get hold of the control if you did not create it. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Raphael" <rafalski30@gazeta.pl> wrote in message news:EA00F864-5105-4C43-9912-8C1...

problem Backing up to thumb drives
When back up to a 4.0 gig cruzer lock thumb drive I get a dialog box that tells me "Money has filled the current disk" "Please insert Backup Disk 2 into the H:\ drive so that we may continue to build your backup." I have 2 of these drives, both have plenty of empty space available and the results are the same on both. I can use a 256 mb thumb drive to back up to without getting this message. Any ideas? Thanks, In microsoft.public.money, BJV wrote: >When back up to a 4.0 gig cruzer lock thumb drive I get a dialog box that >tells me "Money has filled the...

Problems using GetFileVersionInfo
I'm trying to get the file's information from the VS_VERSIONINFO block. I added the header file "winver.h" and included the "version.lib" in the settings. I use the following to start with... // ---- code ----- void GetInfoDlg::GetFileInfo( LPCTSTR lpszFile ) { DWORD dwZero, dwInfoSize; dwInfoSize = GetFileVersionInfoSize( (LPTSTR)lpszFile, &dwZero ); if( dwInfoSize > 0 ) { LPBYTE lpBuf = new BYTE[dwInfoSize]; GetFileVersionInfo( (LPTSTR)lpszFile, 0, dwInfoSize, &lpBuffer ); // get info // TODO: Query the i...