Advanced File Copying

BlitzPlus Forums/BlitzPlus Programming/Advanced File Copying

Luke111(Posted 2009) [#1]
I was trying to debug my MEMORY.DMP file when Windows restricted me from acessing it. I thought of making a program that would do it for me and came up with this:

toread$ = "C:\Windows\MEMORY.DMP"
towrite$ = "C:\Users\LJB\Desktop\mem.dmp"
x$ = OpenFile(toread$)
z$ = WriteFile(towrite$)
.fileread
rl$ = ReadLine$(x$)
WriteLine(z$,rl$)
If Eof(x$) Then
CloseFile z$
CloseFile x$
Else
Goto fileread
EndIf


I then thought of it being added in GUI and made in to a sort of Robocopy type program so im working. If you know how to edit attributes let me know...


Mahan(Posted 2009) [#2]
1.) This is a binary file. You would do much better if you access it with the stream and bank commands in BlitzPlus.

2.) File handles are of type integer (not string or <something>$). Regarding OpenFile(), ReadFile() and WriteFile().

3.) Always try to avoid goto. There are 2 nice loop types in B+ namely While..Wend and Repeat..Until (or Forever) that could help you replace that goto in your example..

4.) If windows restricts access to a file it can be a file-lock. If other programs are not able to open this file for reading, your program wont probably either. What you can do if you absolutely need access to it, is to boot another operating system on another partition, and just open the file and look at it. There are small and nice Linux distributions that can be installed on a thumbdrive, that can you can boot on most PCs today (without altering your original OS)


em22(Posted 2009) [#3]
You will be better off using the Windows debugger to examine crash dumps.

http://www.networkworld.com/news/2005/041105-windows-crash.html


xlsior(Posted 2009) [#4]
If you're making a generic filecopy program: just keep in mind that you may run into maximum file size limitations. IIRC none of the blitz programs can deal with files > 2GB, which may limit practical usefulness... (the >2GB exceeds the maximum int value used for the seek position in the file)


Luke111(Posted 2009) [#5]
Yah I tried debugging it with the VS2008 debugging tool and it gave an error saying file was too large to load in memory. Im running vista sp2 home premium with 4gb ram. Might add some more. Anybody know the vista memory limit??? Lol(Probally 6gb). Gonna get win7 when a stable release comes out.


xlsior(Posted 2009) [#6]
Under 32-bit windows, each application has a 2GB memory limit regardless of how much RAM you have in your PC. There's a tweak you can give to windows boot options to boost that to 3GB IIRC, but that's the absolute max.
Same applies to Vista, you'd need the 64-bit version of windows to be able to be able to go beyond that.

do note that that's just windows' own limitation -- since blitz uses ints for pretty much everything internally, it won't magically be able to use all the memory on its own either since it can't address it all.


Luke111(Posted 2009) [#7]
Thx. I guess memory restrictions should apply as most viruses use a lot of memory. My pc I built has 4gb physical but windows only recognizes it as 3gb physical memory. Probally the conflict with ibm and seagate and such whithin which seagate claimed a gb as 1745000000 or so bytes but ibm said it was 100000000. (Mumbles....)


xlsior(Posted 2009) [#8]
My PC I built has 4gb physical but windows only recognizes it as 3gb physical memory


that's a fun feature of 32-bit.

You only have 2^32 addressable memory locations, and part of them are gobbled up by your motherboard, network card, video RAM, etc, leaving 3 to 3.25GB available for actual RAM on most computers.

If you were running 64-bit windows it would see (and be able to use) the full 4GB, although a 32-bit app would still have the same 2GB-max-per-app restriction.


em22(Posted 2009) [#9]
I didn't say try VS2008 debugging tool. That's not the type of debugging you need to be doing.

I specifically gave you this page :
http://www.networkworld.com/news/2005/041105-windows-crash.html

Which explains how to properly debug you memory.dmp that Windows creates.

You need to install the WinDbg tool from here : http://www.microsoft.com/whdc/devtools/debugging/default.mspx

Nothing else will debug those dumps. It's pointless to try anything else as it would be illogical.