Darkelf
January 24th, 2007, 20:31
Hi,
I'm new to this board and must say that I'm impressed so far. People get really good help here - just in case they ask the right questions
.
I hope I can also answer some questions people may have and give them good advice. But for now I´m the one who has to ask a question. Not on reversing but on programming.
I wonder how it can be realized to circumvent an API-Call. Hooking is not what I mean. I mean doing things that are usually done with a call, without a call - get it?
Let me explain this a bit further. If you code in uuhm... C, and you want to list the contents of a directory, you would probably write something like this:
You see, it needs a call to FindFirstFile, FindNextFile to do the listing. Even when you not call something from the API directly, it will be used internaly. For example:
In this case ReadFile is called. You must think now that I'm stupid posting this simple things here. But I think the answer to my question is not that simple. The question is again: How can I open a file on disk directly, without using an API-Call? I searched through the net and found simply nothing.
I guess it can only be down low-level (assebly) and I furthermore guess it depends on the filesystem used. But all in all I have no idea where to start.
Any help would be apprechiated.
Best regards
Darkelf
btw. I know it's possible, because some rootkit-detectiontools are using such technique, in order to compare the list of files they get by using the API with the list they get doing it manually. I just want to know how.
I'm new to this board and must say that I'm impressed so far. People get really good help here - just in case they ask the right questions

I hope I can also answer some questions people may have and give them good advice. But for now I´m the one who has to ask a question. Not on reversing but on programming.
I wonder how it can be realized to circumvent an API-Call. Hooking is not what I mean. I mean doing things that are usually done with a call, without a call - get it?
Let me explain this a bit further. If you code in uuhm... C, and you want to list the contents of a directory, you would probably write something like this:
Code:
HANDLE handle;
WIN32_FIND_DATA wfd;
handle=FindFirstFile("C:\\*",&wfd);
do
{
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
printf("Directory found: %s\n", wfd.cFileName);
else
printf("%s\n", wfd.cFileName);
}
while (FindNextFile(handle,&wfd));
FindClose(handle);
You see, it needs a call to FindFirstFile, FindNextFile to do the listing. Even when you not call something from the API directly, it will be used internaly. For example:
Code:
if(fopen_s(&infile, name, "rb")
printf("\nCan't open file";
else
{
lit = fgetc(infile);
while(!feof(infile))
{
putchar(lit);
lit = fgetc(infile);
}
fclose(infile);
}
In this case ReadFile is called. You must think now that I'm stupid posting this simple things here. But I think the answer to my question is not that simple. The question is again: How can I open a file on disk directly, without using an API-Call? I searched through the net and found simply nothing.
I guess it can only be down low-level (assebly) and I furthermore guess it depends on the filesystem used. But all in all I have no idea where to start.
Any help would be apprechiated.
Best regards
Darkelf
btw. I know it's possible, because some rootkit-detectiontools are using such technique, in order to compare the list of files they get by using the API with the list they get doing it manually. I just want to know how.