How does PartCopy work ?

Help and discussing programming in C and C++.

Moderator: Moderators

Post Reply
BenBowen
Posts: 12
Joined: Tue Nov 16, 2010 2:12 am
Location: US
Contact:

How does PartCopy work ?

Post by BenBowen » Tue Nov 16, 2010 2:19 am

Before I end up screwing my computer, I want to know the benchmark of PartCopy's clockwork so that I can attempt to write a better version. I'm attempting to create my own Operating System (at least a simple one), but if I do, I want to know how most of my utilities work, and so forth.

So, could some one explain? Thanks in advanced,

Ben

User avatar
Mike
Site Admin
Posts: 465
Joined: Sat Oct 20, 2007 7:58 pm
Contact:

Re: How does PartCopy work ?

Post by Mike » Wed Nov 17, 2010 2:02 am

Hello,

PartCopy provides a method of copying a region of a file or disk of a given size to another file or disk of that same size. The capability of copying over regions of files to another can be done with ISO C file routines. Reading and writing raw sectors on mounted devices must be done through the system API; the Win32 API WriteFile() routine seems to provide this. For Windows Vista and 7, in order to write raw sectors might require administrative rights.

Please note that this information is based on observation only; PartCopy isnt written by us although we can provide in-house source code for an example that does the above.
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

BenBowen
Posts: 12
Joined: Tue Nov 16, 2010 2:12 am
Location: US
Contact:

Re: How does PartCopy work ?

Post by BenBowen » Wed Nov 17, 2010 4:35 am

Pshh, I didn't know it was that simple! :)

Andyhhp
Moderator
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1
Contact:

Re: How does PartCopy work ?

Post by Andyhhp » Wed Nov 17, 2010 11:25 am

Pshh, I didn't know it was that simple! :)


A great many things are a lot more simple than they look.

The key to partcopy is that it doesnt open a normal file - it opens a file which represents the raw data on the disk (something like \\?\Disk\{GUID}\.. but I really dont know windows internal device paths very well)

This is along the same lines of writing to /dev/sdX in unix

At this point, the normal file operations like fread an fwrite work

~Andrew
Image

BenBowen
Posts: 12
Joined: Tue Nov 16, 2010 2:12 am
Location: US
Contact:

Re: How does PartCopy work ?

Post by BenBowen » Thu Nov 18, 2010 4:40 am

Thanks. If I understand correctly, I would need to "find" the GUID for every user-chosen file path? Sorry, but I don't really know what I'm actually after; subjecting about these "GUIDs" and raw data.

EDIT:

And by the way... How do iostream and fstream work? ASM (assembly language)?

Andyhhp
Moderator
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1
Contact:

Re: How does PartCopy work ?

Post by Andyhhp » Thu Nov 18, 2010 8:38 am

No - the GUIDs are per device on the computer - but you really will need a windows reference to know how to use the device paths correctly.

As for iostream and fstream - they are little more than wrappers around the c stdio library in an object orientated fasion.
Image

BenBowen
Posts: 12
Joined: Tue Nov 16, 2010 2:12 am
Location: US
Contact:

Re: How does PartCopy work ?

Post by BenBowen » Thu Nov 18, 2010 3:40 pm

Yes I regularly use MSDN. *checks MSDN* So could you give me an example, just so I can be certain?

Post Reply