| Author |
Message |
   
Sarmad Mehrbod
Username: smehrbod
Registered: N/A
| | Posted on Saturday, Dec 1, 2007 - 23:08: | |
hi i have recently purchased a licence and i am having problem trying to write directly to hard disk physical sectors. Whenever i am using BOOL WHX_Write( LPVOID lpBuffer, int Bytes ); the output (Boolean Value) is 0 and nothing gets written. i also have the same problem with BOOL WHX_Save(); the output is always 0 and no change is being saved! i was wondering if you could provide me with a working C sample file, which includes writing directly to the disk. maybe i am having my parameters wrong or so. if you help me out, i will be delighted! |
   
Stefan Fleischmann
Username: admin
Registered: 1-2001
| | Posted on Saturday, Dec 1, 2007 - 23:13: | |
You could try WHX_OpenEx instead of WHX_Open with Param==0 or Param==2. No, I don't have a C sample file. |
   
Sarmad Mehrbod
Username: smehrbod
Registered: N/A
| | Posted on Tuesday, Dec 4, 2007 - 2:59: | |
Dear Stefan the problem is not that simple, i can even paste the clipboard in to entire cells but i cant still write directly into files,disks etc. i just had a look on other examples for other languages such as VB and i noticed there some other instructions which have not been presented all on the web page bellow: http://www.winhex.com/winhex/api/whxapidoc.html if you can, send me the whole list of API instructions so i might be able to do something at the end. thank you very much Sarmad |
   
Stefan Fleischmann
Username: admin
Registered: 1-2001
| | Posted on Tuesday, Dec 4, 2007 - 9:45: | |
The list of API instructions on the web page that you linked to is complete. There are no API instructions that are not in the list. |
   
Sarmad Mehrbod
Username: smehrbod
Registered: N/A
| | Posted on Wednesday, Dec 5, 2007 - 9:38: | |
Dear Stefan can you fill the parameters in for BOOL WHX_Write(LPVOID lpBuffer,int Bytes ); i believe there is something worng with the parameters iam sending to the instruction what "lpBuffer" should be field with and what kind of varibale type should it be? my project is stopped till i get this bit sorted! i really appreciate your help Thanks Sarmad |
   
Jens Kirschner Username: jenskirschner
Registered: N/A
| | Posted on Wednesday, Dec 5, 2007 - 18:27: | |
lpBuffer would have to be a pointer to a block of data to be written, e.g. a char pointer, an integer array or something holding the data to write. int Bytes is simply the number of bytes to read from lpBuffer and write at the current location. You might also want to ensure that the location you check to see the result is actually also the location there the write is performed, i.e. the location the pointer is aiming at. Nobody but you can possibly know how to fill in the parameters... |
   
Sarmad Mehrbod
Username: smehrbod
Registered: N/A
| | Posted on Thursday, Dec 6, 2007 - 5:34: | |
dear Jens as you said i have tried putting pointers to strings etc. but always the output (Boolean value) of Write instruction is 0; can you have at look at the following lines and tell me if anything is wrong with them? int initRes = WHX_Init(1); if (initRes <= 0) { WHX_Done(); return 1; } if (! WHX_OpenEx("G:\smm.txt", 0x00000002)) { WHX_Done(); return 1; } char buf[256]; WHX_Read(buf, sizeof(buf)); cout << WHX_Write(&buf,sizeof(buf)); WHX_Close(); WHX_Done(); return 0; } i just made it simple to write the read buffer in to the same place but the out put is always zero and nothing gets written! |
   
Jens Kirschner Username: jenskirschner
Registered: N/A
| | Posted on Friday, Dec 7, 2007 - 14:31: | |
How about you cout the result of the read instruction to see if the problem might actually occurr while attempting to read. I haven't done C in a while so I might be off on this one, but it appears to me you are sending "buf" as parameter to the WHX_Read as opposed to a pointer of buf. If memory serves, you are reading into a copy of buf which is valid only inside the function call - and then discarded, i.e. your read data is lost. For WHX_Write, you send the pointer instead, but there it would matter less... Additionally, you might want to check that G:\smm.txt is actually big enough for the initial read instruction. It appears to me, if it is smaller, the pointer for the read will not be moved - and if you read and write the same information in the same place, it will not appear like anything has changed. Overwriting data with itself never looks like anything was written. |