我如何才能找到一个文件的物理地址?物理地址、文件

2023-09-09 21:18:23 作者:老温酒

我使用的 GoAsm汇编在的Windows 7 - 64位 OS,我会问你几个(并非如此愚蠢的)问​​题

第一个问题:

我怎样才能找到一个文件的物理地址? 让我们假设文件TEXT.TXT是我的C盘根:\分区。 有没有办法得到确切的内存地址在此文件?

第二个问题:

时可以调用,这将只是不喜欢,如果我调用的C函数例行?

(即:考虑一个C函数WriteToScreen,是有可能有同样的功能,但在汇编格式,这意味着无需需要使用高级别调用该工作

第三个问题:

是否有某个地方在网络上的一些包括含有例如有用的程序文件GoAsm(移动,复制,编辑,删除)命令?我已经对MS-DOS中断,第一个想到的,但我不能设法让他们没有崩溃的程序中工作。我想这只是与Windows操作系统即使在命令提示符下的行为像 MS-DOS ...

不兼容

第四个问题:

我已经听到来自不同的来源和自己说NASM工作pretty的坏在 Win7的X64 ,它只是真实的,还是我做了错误的方式?

解决方案

1 一个硬盘驱动器,从逻辑上来看,可以看作是块(更常见的名是扇区)的序列。如何将这些块物理地组织在磁盘上可以忽略不计,但司机必须知道好歹如何获得,当然数据,虽然你发送给现代HD驱动程序的高级别的命令是,只要你知道,是不是强相关到数据实际是(你可以说读取块123,但也正是该块的生命存在extern证据)。

不过这种方式,您可以在名与许多块,并说如该块0是MBR。每个块包含几个字节(512,1024 ...)。并非所有使用的块包含文件的实际数据,实际上有任何形式的metainformations,根据不同的文件系统,但即使涉及到高清的结构(我的意思是,分区)。

位于一个高清文件不会自动加载到内存中,所以它没有记忆的地址。一旦你读它,一块,如果不是所有的课程都复制到你给的记忆,这是不是文件的固有财产。 (文件系统检索属于文件和秀出来的块,我们习惯看到他们,作为一个单一的单元,该文件)

汇总:文件没有内存地址。物理地址可以是一组保存数据块(和元数据,如的inode )文件,或者仅仅第一块的(但如果一个数据块为N,N + 1的不能属于同一文件 - 该块不需要是一个接一个的其他)。要认识他们,你要分析你使用的文件系统的结构。我不知道是否有一个API可以轻松地检索它们,但在最坏的情况下,你可以分析文件系统的源$ C ​​$ C ...祝你好运!

2 C函数被翻译成汇编。如果你尊重C调用约定,你可以直接用汇编写了一个C函数。尝试阅读这和的这个为86。

3 您可以从ASM调用Windows API。忘了MS-DOS,MS-DOS是死,MS-DOS不是Windows下的cmd是一种模拟......确实没有,不是一个仿真而只是一个命令行界面类似于一个MS-DOS用户来。但它不是exaclty相同的,即没有MS-DOS系统中断,您可以使用。 Iczelion的组装教程的,虽然老了,可能是一个有趣的资源。 (如果链接失效,尝试用 Wayback机器)

4 我没有自己的Win7,从不安装在Windows NASM,所以我不能说任何东西。

I'm using the GoAsm assembler on a Windows 7 - 64 bit OS and I'll be asking you a few (not so dumb) questions.

First question :

win7下如何用批处理文件实现自动修改网卡物理地址为0016EC9FA659

How can I find the physical address of a file ? Let's suppose file "Text.txt" is at the root of my C:\ partition. Is there a way to get the exact memory address where this file is ?

Second question :

Is it possible to call a routine which will just do like if I invoked a C function ?

(i.e. : Consider a C function "WriteToScreen", is it possible to have the same function, but in assembler format, that means without having the need to use high-level invokes to do that work ?

Third question :

Are there somewhere on the net some include files for GoAsm containing useful routines like (move, copy, edit, erase) commands ? I've first thought of ms-dos interrupts but I can't manage to get them to work without crashing the program. I guess it just not compatible with Windows OS even though the command prompt acts like ms-dos... ?

Fourth question :

I've heard from different sources and myself that NASM works pretty bad on Win7 x64, is it just true, or am I doing it the wrong way ?

解决方案

1 An hard drive, from a logical point of view, can be seen as a sequence of "blocks" (the more common name is sectors). How these blocks are organized physically on the disks can be disregarded, but the driver must know someway how to get data of course, though you send to modern hd driver "high level" commands that, as far as you know, are not strongly related to where data physically are (you can say "read the block 123", but there's no extern evidence of where that block lives).

However this way you can "name" a block with a number, and say e.g. that block 0 is the MBR. Each block contains several bytes (512, 1024...). Not all used blocks contain actual data of a file, in fact there are metainformations of any sort, depending on the filesystem but even related to the "structure" of the hd (I mean, partitions).

A file located on an hd is not automatically loaded into memory, so it has no memory address. Once you read it, piece of it if not all are of course copied into the memory you give, which is not an intrinsic property of the file. (Filesystems retrieve the blocks belonging to the file and "show" them as we are used to see them, as a single "unit", the file)

Summarizing: files have no memory address. The physical address could be the set of blocks holding data (and metadata, like inodes ) of the file, or just the first block (but if a block of data is N, N+1 could not belong to the same file - the blocks need no to be one next to the other). To know them, you have to analyse the structure of the filesystem you use. I don't know if there's an API to retrieve them easily, but in the worst case you can analyse the source code of the filesystem... good luck!

2 C functions are translated into assembly. If you respect the C calling convention, you can write a "C function" directly in assembly. Try reading this and this for x86.

3 You can call windows API from asm. Forget MS-DOS, MS-DOS is dead, MS-DOS is not Windows, the cmd is a sort of "emulation"... indeed no, not an emulation but just a command line interface that resemble the one MS-DOS users was used to. But it is not exaclty the same, i.e. there are no MS-DOS system interrupt you can use. Iczelion's assembly tutorials, though old, could be an interesting resource. (If links expire, try with the wayback machine)

4 I do not own Win7 and never installed nasm on windows, so I can't say anything about.