[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 315
  • Last Modified:

How to manually modify a size of a file ?

Hi,

First of all,sorry if I make mistakes but I am not english :)
I have found  a floppy disk with a file of 750Mo.
It sounds like the cd-protection.

I am verry curious and I would like to know how is it possible.
I think it s an hexa value to modify in the structure of a little file but how can we do ?

Thanks for your responses.

0
bigstyle
Asked:
bigstyle
  • 7
  • 6
  • 5
  • +1
1 Solution
 
sunnycoderCommented:
Hi bigstyle,

you cannot modify the file size except by actually increasing it ... The file size is stored in system variables (or calculated from them depending on fs and implementation )

Cheers!
Sunny:o)
0
 
jhanceCommented:
The file's size is stored in the DIRECTORY of the storage device.  Windows 2000 does not go out and calculate the size of every file on the media when you list the directory.  It merely uses the size stored in the directory.

A corrupted (or intentionally modified) directory could display an invalid file size.  This is commonly done by software protection schemes for games and the like.  By misrepresnting the size of files on a CD, copying is made more difficult since CD copying programs can be fooled.

You could certainly do (or correct) this yourself but the details depend on the FILE SYSTEM used on your media.  If indeed this is a floppy, the filesystem is likely FAT.  The details of the FAT file system and its directory structure are well documented.

http://www.pcguide.com/ref/hdd/file/fat.htm
0
 
bigstyleAuthor Commented:
Thanks you both for your answers.

I would like to try to increase the file Sunny;

Jhance,I visited your website but I didnt have seen something interesting.

I remember a method that was to modify the header of an image file (iso file ?) but I dont remember how,and moreover I would like to know how it is possible for every kind of files.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
sunnycoderCommented:
>The file's size is stored in the DIRECTORY of the storage device.  Windows 2000 does not go out and calculate the size of
>every file on the media when you list the directory.  It merely uses the size stored in the directory.
jhance, if you meant total disk space occupied by the directory, then I am inclined to disbelieve this ... if you meant individual file, I agree.

bigstyle
you can increase file size by appending any data to it ... just that you will end up trashing the file but file size will increase.

While it is possible to modify the values of filesize stored on a floppy, it should not be so trivial for files on your hard disk (if it is, virii and worms would have a ball) ....
0
 
jhanceCommented:
sunny...,

No you can modify the apparent size of any file on the disk by messing with the directory information in the filesystem's directory.

As I already said, this is commonly done as an [easily circumvented] copy protection scheme for CDs.  It was also done in the past with floppies.

Doing this on a hard drive, however, is NOT recommended as you risk trashing the entire filesystem.
0
 
sunnycoderCommented:
>on the disk
floppy disk easy ... but with hard disk I am not so sure ... I know it is possible on linux by overwriting inodes and other data structures (as a super user) but windows ... ????
0
 
jhanceCommented:
Same technique, just different details due to different filesystem.  But all of these work in generally the same way.
0
 
bigstyleAuthor Commented:
But nobody said how it is concretely possible to modify the size of a file in a floppy :/

jhance it seems you know how to do in every situation,could you please be more precise ?

Thanks
0
 
jhanceCommented:
1) You valued this question at 100 pts.  That means, in effect, "I need only a pointer in the right direction and can take it from there..."
2) I posted you a URL to a full description of the FAT16 filesystem format that is used on floppies under Windows 2000.  The information is right there even though you claim otherwise.
3) If you need more assistance or a complete solution, please value this question appropriately.
0
 
bigstyleAuthor Commented:
lol jhance,
i didnt know that the rules were so weerd there.

Here is 200 points more,that s enough for having more knowledge ? :)
0
 
bigstyleAuthor Commented:
450 points sorry for the bad manipulation
0
 
jhanceCommented:
bigstyle,

Here is a quick-and-dirty example.  It takes a standard 1.4M/FAT floppy, reads the directory, DOUBLES the size of the first file in the directory, and writes the directory back to the disk.  Note that the file itself is not changed but that if you run CHKDISK or SCANDSK on this floppy, there will be an error since the file does not actually take that much room.  You can use this technique to set the file to any amount you choose.

Enjoy but please be careful.  Using this on a hard drive could be disastrous!!!


#include "stdafx.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
      HANDLE hFloppy = CreateFile(
                  "\\\\.\\A:",                              // Open the A: drive for PHYSICAL ACCESS
                  GENERIC_READ | GENERIC_WRITE,      // Want R/W Access
                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                  NULL,
                  OPEN_EXISTING,
                  0,
                  NULL
            );

      if(hFloppy == INVALID_HANDLE_VALUE){
            cout << "Error opening FLOPPY drive. Error is: " << GetLastError() << endl;
            return -1;
      }
      else{
            cout << "Floppy device opened ok." << endl;
      }

      DWORD dwRead = 0;
      DWORD dwWrite = 0;
      UCHAR *pBuffer;
      pBuffer = new UCHAR[1024 * 16];

      if(ReadFile(hFloppy, (LPVOID)pBuffer, 1024 * 16, &dwRead, NULL)){
            cout << "Read OK..." << endl;

            // Make a pointer to the SIZE of the first file on the floppy
            DWORD *pSize = (DWORD *)((DWORD)pBuffer + 0x0000261c);
            DWORD dwSize = *pSize;
            dwSize = dwSize * 2;
            *pSize = dwSize;

            // Write the modified data back to disk
            SetFilePointer(hFloppy, 0, 0, FILE_BEGIN);

            if(WriteFile(hFloppy, (LPVOID)pBuffer, 1024 * 16, &dwWrite, NULL)){
                  cout << "Write OK..." << endl;
                  FlushFileBuffers(hFloppy);
            }
            else{
                  cout << "Write failed: " << GetLastError() << endl;
            }
      }
      else{
            cout << "Read Failed: " << GetLastError() << endl;
      }

      delete [] pBuffer;

      CloseHandle(hFloppy);

      return 0;
}
0
 
jhanceCommented:
Any further questions?  Comments?
0
 
jhanceCommented:
Hello???
0
 
bigstylerCommented:
Weel I have tried this code but it doesnt work so the question is still opened.
Sorry
0
 
sunnycoderCommented:
I second the recommendation
jhance had pinged the asker twice
0
 
bigstylerCommented:
ok give him the points if you want, even if for me the answer is uncomplete.
0
 
sunnycoderCommented:
bigstyle == bigstyler

Holding multiple accounts is voilation of membership agreement
http://www.experts-exchange.com/memberAgreement.jsp
0
 
bigstylerCommented:
Erf sorry I have an account for my job and one for my personal use :/
0
 
bigstylerCommented:
Ok you can delete bigstyle account ...
0
 
bigstylerCommented:
doesnt matter.

I have more points in bigstyle account but I have lost my password and the "Forgot Password" method doesn't work.
Give him the points if you want.
0
 
bigstylerCommented:
Thank you for the points report
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 7
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now