Low level disc access under windows with FPC

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Low level disc access under windows with FPC

pianoman-3
        Hello, I'd like to ask if someone has experiences with low level
disk operations in windows with FPC.
The program should be able to copy entire diskete to one single image file
and for example extract a single file from that image or view its contents.

For example how can I read one sector from disk in to buffer?
Thanx for help
Pianoman

----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Saturday, October 07, 2006 5:08 AM
Subject: fpc-pascal Digest, Vol 26, Issue 18


> Send fpc-pascal mailing list submissions to
> [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> or, via email, send a message with subject or body 'help' to
> [hidden email]
>
> You can reach the person managing the list at
> [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of fpc-pascal digest..."
>
>
> Today's Topics:
>
>   1. Re:  RE: Get Local IP using glib (eth0,eth1) (Graeme Geldenhuys)
>   2. Re:  RE: Get Local IP using glib (eth0,eth1) (Marco van de Voort)
>   3. Re:  Unistalling FPC (and reinstalling from svn) (Jochem Berndsen)
>   4. Re:  RE: Get Local IP using glib (eth0,eth1) (TOUZEAU DAVID)
>   5.  visualserver from VisualSynapse how implement it as a Linux
>      console Daemon (TOUZEAU DAVID)
>   6.  THREADVARLIST_FVCOMMON & THREADVARLIST_MEMORY undefined
>      symbols while linking (Ken G. Brown)
>   7. Re:  RE: h2pas error report (Marc Santhoff)
>   8.  Install freepascal Mysql package to kylix 3
>      ([hidden email])
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 6 Oct 2006 16:27:58 +0200
> From: "Graeme Geldenhuys" <[hidden email]>
> Subject: Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
> To: "FPC-Pascal users discussions" <[hidden email]>
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I have these two functions in my .bashrc file.  You only need to run
> "ii" for the cool output.  Now back to the question -  If it is for
> linux only, why not just use the /sbin/ifconfig output.  After all, it
> is accurate and seem much easier than all those libc/library methods.
> I pull the IPs and Interfaces available from the /sbin/ifconfig output
> and works just fine.  If it was needed on windows, I am sure you could
> to the same thing with the 'ipconfig' output.
>
> My 2c worth!  :-)
>
>
> Regards,
>  - Graeme -
>
>
>
> ------------ .bashrc ---------------------
> function my_ip() # get IP adresses
> {
>    MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e
> s/addr://)
>    MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed
> -e s/P-t-P://)
> }
>
> function ii()   # get current host related info
> {
>    echo -e "\nYou are logged on ${RED}$HOST"
>    echo -e "\nAdditionnal information:$NC " ; uname -a
>    echo -e "\n${RED}Users logged on:$NC " ; w -h
>    echo -e "\n${RED}Current date :$NC " ; date
>    echo -e "\n${RED}Machine stats :$NC " ; uptime
>    echo -e "\n${RED}Memory stats :$NC " ; free
>    my_ip 2>&- ;
>    echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not
> connected"}
>    echo -e "\n${RED}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}
>    echo
> }
> ---------------------------------
>
> On 06/10/06, Jeff Pohlmeyer <[hidden email]> wrote:
>> > Better, but still Linux only. For a good solution,
>> > a resolver unit that accesses libc should be
>> > written that is portable (unlike the libc unit)
>>
>>
>> If I understood correctly, the OP had two questions:
>>
>> 1. Retrieve a list of interface names on a *linux* system.
>> 2. Return the IP address for a given *linux* interface name.
>>
>>
>> And the only "good" solution is a portable resolver unit?
>>
>> How will you resolve "eth0" on Win32 or BSD ?
>>
>>  -Jeff
>
>
> --
> There's no place like 127.0.0.1
>
>
> ------------------------------
>
> Message: 2
> Date: Fri, 6 Oct 2006 16:33:35 +0200 (CEST)
> From: [hidden email] (Marco van de Voort)
> Subject: Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset="US-ASCII"
>
>> > Better, but still Linux only. For a good solution,
>> > a resolver unit that accesses libc should be
>> > written that is portable (unlike the libc unit)
>>
>> If I understood correctly, the OP had two questions:
>>
>> 1. Retrieve a list of interface names on a *linux* system.
>> 2. Return the IP address for a given *linux* interface name.
>
> I don't understand that last one. _WHY_ would you want to enumerate and
> then
> still use hardcoded "eth0" What if eth0 is my internal and eth1 my
> external
> interface? The only meaning of the name is order of detection.
>
>> And the only "good" solution is a portable resolver unit?
>>
>> How will you resolve "eth0" on Win32 or BSD ?
>
> Usually you enumerate the interfaces list, till you find the interface
> with
> the "default" (ANY) route, so you have the default gateway, regardless of
> name. That is usually the interface you interested in.
>
> IOW names say nothing, routes and masks do.
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 6 Oct 2006 10:54:50 +0200
> From: Jochem Berndsen <[hidden email]>
> Subject: Re: [fpc-pascal] Unistalling FPC (and reinstalling from svn)
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain;  charset="iso-8859-1"
>
> On Friday 06 October 2006 10:49, Adrian Maier wrote:
>> I have a silly question :  which is the best way to uninstall FPC ?
> I don't know.
>
>> Also, after compiling FPC  with 'make build'  ,  if i execute 'make
>> install'  will it
>> copy everyting in  /usr/local   by default ?   Is the destination
>> directory configurable
>> somehow?
> Yes. You can choose the installation directory using
> make install INSTALL_PREFIX=/path/to/install
> (For example,
> make install INSTALL_PREFIX=/usr/local
> This will create bin/ and lib/ and other directories if they do not exist
> already.)
>
> Jochem.
>
>
> ------------------------------
>
> Message: 4
> Date: Fri, 06 Oct 2006 17:53:33 +0200
> From: TOUZEAU DAVID <[hidden email]>
> Subject: Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Many thanks to the community
>
> To reply to Graeme :
> why not just use the /sbin/ifconfig output ?
> Simply to be more dev compliance... using an external program is slower
> and sometime ifconfig doesn't exist or is deleted on target computers.
>
> To reply to Marco :
> And the only "good" solution is a portable resolver unit?
> How will you resolve "eth0" on Win32 or BSD ?
>
> For WIN32, i d'ont care because the program is only for Linux systems.
> Your are true, in BSD the network interface is not the same and i must
> detect wich interface is used...
>
> Best regards
>
>
>
>
>
>
> Graeme Geldenhuys a écrit :
>> I have these two functions in my .bashrc file.  You only need to run
>> "ii" for the cool output.  Now back to the question -  If it is for
>> linux only, why not just use the /sbin/ifconfig output.  After all, it
>> is accurate and seem much easier than all those libc/library methods.
>> I pull the IPs and Interfaces available from the /sbin/ifconfig output
>> and works just fine.  If it was needed on windows, I am sure you could
>> to the same thing with the 'ipconfig' output.
>>
>> My 2c worth!  :-)
>>
>>
>> Regards,
>>  - Graeme -
>>
>>
>>
>> ------------ .bashrc ---------------------
>> function my_ip() # get IP adresses
>> {
>>    MY_IP=$(/sbin/ifconfig eth0 | awk '/inet/ { print $2 } ' | sed -e
>> s/addr://)
>>    MY_ISP=$(/sbin/ifconfig ppp0 | awk '/P-t-P/ { print $3 } ' | sed
>> -e s/P-t-P://)
>> }
>>
>> function ii()   # get current host related info
>> {
>>    echo -e "\nYou are logged on ${RED}$HOST"
>>    echo -e "\nAdditionnal information:$NC " ; uname -a
>>    echo -e "\n${RED}Users logged on:$NC " ; w -h
>>    echo -e "\n${RED}Current date :$NC " ; date
>>    echo -e "\n${RED}Machine stats :$NC " ; uptime
>>    echo -e "\n${RED}Memory stats :$NC " ; free
>>    my_ip 2>&- ;
>>    echo -e "\n${RED}Local IP Address :$NC" ; echo ${MY_IP:-"Not
>> connected"}
>>    echo -e "\n${RED}ISP Address :$NC" ; echo ${MY_ISP:-"Not connected"}
>>    echo
>> }
>> ---------------------------------
>>
>> On 06/10/06, Jeff Pohlmeyer <[hidden email]> wrote:
>>> > Better, but still Linux only. For a good solution,
>>> > a resolver unit that accesses libc should be
>>> > written that is portable (unlike the libc unit)
>>>
>>>
>>> If I understood correctly, the OP had two questions:
>>>
>>> 1. Retrieve a list of interface names on a *linux* system.
>>> 2. Return the IP address for a given *linux* interface name.
>>>
>>>
>>> And the only "good" solution is a portable resolver unit?
>>>
>>> How will you resolve "eth0" on Win32 or BSD ?
>>>
>>>  -Jeff
>>
>>
>
> --
>
> David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
> FreePascal-Lazarus,perl,delphi,php icq:160018849
>
>
>
> ------------------------------
>
> Message: 5
> Date: Fri, 06 Oct 2006 18:02:25 +0200
> From: TOUZEAU DAVID <[hidden email]>
> Subject: [fpc-pascal] visualserver from VisualSynapse how implement it
> as a Linux console Daemon
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Dear
>
> is anybody there use visualserver from VisualSynapse
> (http://visualsynapse.sourceforge.net/?id=8) and impleted it on Linux
> has a console mode...??
> Examples given is only on application interface ...
>
> Problems:
>
> 1) When the application start, no web page are generated...
> 2) i would like to develop a variant of this web server. In this case, i
> need to trap the requests received by the process.
>
> Here it is a sample that didn't working
>
> //*************************************************************************************************
> program shttpserver;
>
> {$mode objfpc}{$H+}
>
> uses
> //ArticaAgent
>  cthreads,custapp, Classes, SysUtils, fpcunit,httpserver ;
>
> const
>  Version = 'Version 0.1';
>
> type
>  TTestRunner = class(TCustomApplication)
>  private
>
>
>  protected
>    procedure DoRun; override;
>  public
>  procedure Listen(receive:string);
>  end;
>
> procedure TTestRunner.DoRun;
>  var
>    I: integer;
>    S: string;
>  begin
>   //  writeln('create...');
>   end;
>
> procedure TTestRunner.Listen(receive:string);
>  begin
>   //  writeln('string received: ' + receive);
>   end;
>
> var
>  App: TTestRunner;
>  eHTTP : TvsHTTPServer;
> begin
>  App := TTestRunner.Create(nil);
>  eHTTP := TvsHTTPServer.Create(nil);
>  eHTTP.LogFile := 'httplog.log';
>  eHTTP.ServerName := 'Visual Synapse Demo HTTP Server';
>  eHTTP.ListenPort := '8000';
>  eHTTP.SSL := False;
>  eHTTP.ListenIP := '0.0.0.0'; //any
>  eHTTP.RegisterDir ('/home/touzeau/Desktop/visualserverdemo/web', '/');
>  eHTTP.RegisterDefaultDoc('index.htm');
>  eHTTP.Active := True;
> // eHTTP.OnGet := @App.Listen; //not working it seems that here i can
> receive requests from clients.
>
>  App.Initialize;
>  App.Title := 'Console  www.';
>  App.Run;
>  App.Free;
> end.
>
> //*************************************************************************************************
>
> --
>
> David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
> FreePascal-Lazarus,perl,delphi,php icq:160018849
>
>
> ------------------------------
>
> Message: 6
> Date: Fri, 6 Oct 2006 10:26:24 -0600
> From: "Ken G. Brown" <[hidden email]>
> Subject: [fpc-pascal] THREADVARLIST_FVCOMMON & THREADVARLIST_MEMORY
> undefined symbols while linking
> To: [hidden email]
> Message-ID: <p06240405c14c33672a40@[169.254.1.2]>
> Content-Type: text/plain; charset="us-ascii"
>
> Downloaded fpc 2.0.4 yesterday and I am trying to compile a legacy CW Pro
> 2 app on Mac 10.4.8 with Xcode 2.4.
> I am getting undefined symbols THREADVARLIST_FVCOMMON &
> THREADVARLIST_MEMORY when trying to link, and I have no clue how to get
> past this problem. I searched my hard drive and found them showing up in
> /myDevelopment/PrtTstfpc/build/PrtTstfpc.build/DerivedSources/ppc/program.s
> but do not know what this means or what to do.
> Any help would be appreciated.
> Thx
> Ken
>
>
> ------------------------------
>
> Message: 7
> Date: Sat, 07 Oct 2006 03:05:02 +0200
> From: Marc Santhoff <[hidden email]>
> Subject: Re: [fpc-pascal] RE: h2pas error report
> To: FPC-Pascal users discussions <[hidden email]>
> Message-ID: <[hidden email]>
> Content-Type: text/plain
>
> Am Donnerstag, den 05.10.2006, 22:19 -0500 schrieb Jeff Pohlmeyer:
>> > Errm, I actually forgot the obvious questions:
>> > What's wrong here? How can I get around it?
>>
>>
>> cat input.h | awk '{gsub(/\<__int64\>/," long long "); print}'  >
>> output.h
>>
>>  - should work, at least on Linux x86
>
> That has done the trick. At least h2pas runs through and I'll see later,
> if the type change makes any difference on windows.
>
> Many thanks Jeff,
> Marc
>
>
>
>
> ------------------------------
>
> Message: 8
> Date: Sat, 7 Oct 2006 11:37:15 +0800 (HKT)
> From: [hidden email]
> Subject: [fpc-pascal] Install freepascal Mysql package to kylix 3
> To: [hidden email]
> Message-ID:
> <[hidden email]>
> Content-Type: text/plain;charset=iso-8859-1
>
> Hi, does anyone know how to install freepascal mysql component to kylix 3
> open edition? Or is there any database component that can be use with
> kylix 3 open edition?
>
> Thx b4.
>
> =============
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
> End of fpc-pascal Digest, Vol 26, Issue 18
> ******************************************
>

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Low level disc access under windows with FPC

Michael Van Canneyt


On Sun, 8 Oct 2006, Pianoman wrote:

>        Hello, I'd like to ask if someone has experiences with low level
> disk operations in windows with FPC.
> The program should be able to copy entire diskete to one single image file
> and for example extract a single file from that image or view its contents.
>
> For example how can I read one sector from disk in to buffer?

I may be wrong, but I don't think Windows allows this, unless you write
a Windows Driver or maybe an old DOS program.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Low level disc access under windows with FPC

Vinzent Höfler
In reply to this post by pianoman-3
On Sunday 08 October 2006 12:08, Pianoman wrote:

>         Hello, I'd like to ask if someone has experiences with low
> level disk operations in windows with FPC.
> The program should be able to copy entire diskete to one single image
> file and for example extract a single file from that image or view
> its contents.

http://www.winmag.com/library/1995/0695/06howtoc.htm:

-- 8< -- snip --
To open a disk for direct access, you use the Win32 CreateFile function
with a special format to specify the name of the disk (a floppy or a
partition on a hard disk): "\\\\.\\a: " to open the a: floppy and "\\\.
\\c: " to open the c: partition on a hard disk.

On hard disks, you can even get direct access at the physical device
level, bypassing the partition structure. This is done with the special
name "\\\\.\\PhysicalDriveN," where N is the number of the hard disk,
starting with 0. If you have only one physical hard disk, it's
PhysicalDrive0, no matter how many partitions you have.
-- 8< -- snip --

So creating a floppy image seems fairly easy (provided you have the
rights to access the disk in that way at all), but extracting a file
from a disk image may be harder because that would require knowledge of
the file system in question unless Windows has some sort of "mount"
feature for such image files.


HTH,

Vinzent.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal