|
rukita wrote: but it seems to me that the result dispalyed is wrong!
Well without knowing what results you expect to see and what results you actually see it is difficult to guess what the problem is. However I would make some suggestions about your code (I think your fread() calls may be wrong).
In lines like:
fread (ogg->magic_number,4,1,fichier);
Instead of hard coding your size values use the sizeof() operator to ensure you are correct, thus:
fread (ogg->magic_number, sizeof(char), 4, fichier);
You also need to add the addressof operator & for the non-array items thus:
fread (&ogg->version, sizeof(int), 1, fichier);
and the same with your conv() function.
It's time for a new signature.
|
|
|
|
|
hey Richard,
Thanks for your answer. i've changed my code. However i still do not know if what is dipakyed is correct or not. So, is there a way to know it? All what i know about the Ogg layout is, that an ogg page header is composed of:
Capture pattern – 32 bits
The capture pattern or sync code is a magic number used to ensure synchronisation when parsing Ogg files. Every page starts with the four ASCII character sequence OggS.
Version – 8 bits
This field indicates the version of the Ogg bitstream format. It is currently mandated to be 0.
Header type – 8 bits
This is an 8 bit field of flags, which indicates the type of page that follows. The rightmost or least significant bit is considered bit 0, with value 0x01, the next least significant digit is bit 1, with value 0x02. The third is bit 2, with value 0x04, and so on.
Granule position – 64 bits
A granule position is the time marker in Ogg files. It is an abstract value, whose meaning is determined by the codec. It may for example be a count of the number of samples, the number of frames or a more complex scheme.
Bitstream serial number – 32 bits
This field is a serial number that identifies a page as belonging to a particular logical bitstream. Each logical bitstream in a file has a unique value, and this field allows implementations to deliver the pages to the appropriate decoder.
Page sequence number – 32 bits
This field is a monotonically increasing field for each logical bitstream. The first page is 0, the second 1, etc. This allows implementations to detect when data has been lost.
Checksum – 32 bits
This field provides a checksum of the data in the entire page, performed with the checksum field set to 0.
Page segments – 8 bits
This field indicates the number of segments that exist in this page. It also indicates how many bytes are in the segment table that follows this field. There can be a maximum of 255 segments in any one page.
Segment table
The segment table is an 8 bit vector of values indicating the length of each segment within the page body. The number of segments is determined from the preceding Page Segments field. Each segment is between 0 and 255 bytes in length.
and here is my new code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef struct
{
char magic_number[4];
int version;
long header_type;
int granule_position;
long bitstream_serial_number;
int page_sequence_number;
int crc;
int page_segments;
int segment_table;
} OggS;
OggS* lecture(char*) ;
main (void)
{
char nom[100];
OggS* ogg;
printf("Veuillez entrer le nom et chemin du fichier OGG sans l'extension .ogg :\n");
gets(nom);
strcat(nom,".ogg");
ogg=lecture(nom);
printf ("The magic_number is:\t %.4s\n",ogg-> magic_number);
printf ("Version du fichier :%d\n",ogg->version);
printf ("Le type du header du fichier :\t %d\n",ogg->header_type);
printf ("Le granule position du fichier :\t %d\n",ogg->granule_position);
printf ("Le bitstream_serial_number :\t%d\n",ogg->bitstream_serial_number);
printf ("page_sequence_number :\t %d\n",ogg->page_sequence_number);
printf ("crc :\t\t %d\n",ogg->crc);
printf ("page_segments :\t\t %d\n",ogg->page_segments);
printf ("segment_table :\t\t\t %d\n",ogg->segment_table);
}
OggS* lecture(char* nom)
{
unsigned char temp[4];
OggS *ogg;
FILE * fichier;
ogg=(OggS*)malloc(sizeof(OggS));
fichier = fopen (nom,"r");
fread (ogg->magic_number,4,1,fichier);
fread (&ogg->version,sizeof(int),1,fichier);
fread (&ogg->header_type,sizeof(long),8,fichier);
ogg->header_type = conv (temp,2);
fread (&ogg->granule_position,sizeof(int),1,fichier);
ogg->granule_position = conv (temp,4);
fread (&ogg->bitstream_serial_number,sizeof(long),1,fichier);
fread (&ogg->page_sequence_number,sizeof(int),1,fichier);
ogg->page_sequence_number = conv(temp,4);
fread (&ogg->crc,sizeof(int),1,fichier);
ogg->crc = conv (temp,2);
fread (&ogg->page_segments,sizeof(int),1,fichier);
ogg->page_segments = conv (temp,2);
fread (&ogg->segment_table,sizeof(int),1,fichier);
fclose(fichier);
return ogg;
}
int conv (unsigned char hex[4],int nb)
{
int res=0,i;
for (i=nb-1;i>=0;i--)res=res*256+hex[i];
return res;
}
please can u help me??
|
|
|
|
|
Well the first thing I noticed is that you are reading an integer (32 bits) for the version, which you state is 8 bits wide, so you should be reading a byte. Check the rest of your code to ensure it is consistent. You could probably make it much easier by the use of a packed structure (check the #pragma pack() and struct keywords in the C++ documentation.
As for any further information I would suggest you do some research on the internet for documentation about the ogg file format (I have not used it before), as you may well find some existing programs or libraries that will help you to read it.
It's time for a new signature.
|
|
|
|
|
On my local machine are a number of user accounts. When I use either NetUserEnum() or NetQueryDisplayInformation() to get those, I always get a few extra. For example, HelpAssistant and SUPPORT_388945a0.
Here's the code I'm using:
LPUSER_INFO_0 pTmpBuf;
DWORD dwEntriesRead,
dwTotalEntries;
NetUserEnum(NULL, 0, FILTER_NORMAL_ACCOUNT, (LPBYTE *) &pTmpBuf, MAX_PREFERRED_LENGTH, &dwEntriesRead, &dwTotalEntries, NULL);
LPUSER_INFO_0 pBuf = pTmpBuf;
for (; dwTotalEntries > 0; dwTotalEntries--)
{
_tprintf(_T("%s\n"), pBuf->usri0_name);
pBuf++;
}
NetApiBufferFree(pTmpBuf); Any idea how I can exclude those other user accounts?
Thanks.
- DC
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Oh boy! I wish it was that easy to remember what I did almost 10 years back. I have done exactly what you trying to do. The gist of it is
a. Initially you get all the accounts, including the ones you never seen or heard of in the system, some don't even show in the accounts list of the User Control Panel
b. I was trying to get the user names which show in the log on screen ONLY
Then you going to call NetUserGetInfo for every user. I think using level 11, USER_INFO_11 will give more detail about the account including the type. I thought there is somewhere you can query for "interactive?" turned on. By interactive it means the user name can be used to login interactively to the system.
I hope, I could be more helpful, but the thought is killing me. I hope this leads you to the right direction.
|
|
|
|
|
Hello all,
I am detecting deletion of files on the system and to do this i am hooking the NtSetInformationFile function. this gets passed to it the file handle, and from this i need the file name. so i am using the API GetFileInformationByHandleEx to get the file name, But the problem is that the file name comes like this "\sample\a.txt", Now this doesn't give me device name(\device\volume) with File name, so i cannot assume from where the file has been accessed, It could be "C:\sample\a.txt" or "D:\sample\a.txt".
So it's quite clear that i must have "\Device\volume0", "\Device\volume1" etc before the filename, Further googling took me to THIS page where the file name can be retrieved from FileHandle, This uses CreateFileMapping, MapViewOfFile, GetMappedFileName, GetLogicalDriveStrings and QueryDosDevice to retrieve the file name, But when i use it CreateFileMapping fail with error 5 which is "Access Denied", Some more google and i found that the file handle must have GENERIC_READ access else CreateFileMapping will fail.
Now i'm not opening the file, explorer is.. So how could i check with which access explorer opens or access the file or how could i change the dwDesiredAccess..
Thanks All..
|
|
|
|
|
Skimming this MSDN page[^] tells me it isn't really simple, however it also suggests me one could call GetFileInformationByHandleEx more than once, with different values for FileInformationClass, and then combine the results.
|
|
|
|
|
Thanks for the reply, and yes we can call GetFileInformationByHandleEx more than once, But i don't see any value returning the Drive letter or Device name of drive where the file is located in FileInformationClass unless i'm missing something..
|
|
|
|
|
As GetFileInformationByHandleEx won't give me the device name, I'm using GetFileInformationByHandle to get the volume number and hopefully compare the number with drive manually.. But the dwVolumeSerialNumber reurns some garbage value..
BY_HANDLE_FILE_INFORMATION info;
DWORD dwSerialNumber = 0;
if(GetFileInformationByHandle(FileHandle, &info) != 0)
{
dwSerialNumber = info.dwVolumeSerialNumber;
swprintf(szTemp, L"The Volume Serial Number = %d", info.dwVolumeSerialNumber);
MessageBox(NULL, szTemp, L"Success", MB_OK);
}
else
{
swprintf(szTemp, L"GetFileInformationByHandle Error = %d", GetLastError());
MessageBox(NULL, szTemp, L"Success", MB_OK);
}
|
|
|
|
|
I think it's done, I don't know if it's ugly...
I used GetFileInformationByHandleEx to get the truncated file name, GetFileInformationByHandle to get the volume serial number, GetLogicalDriveStrings to get all the drives and GetVolumeInformation to get the volume serial number of all the drives, I then compare volume serial number returned by GetVolumeInformation and GetFileInformationByHandle, If it matches then it concatenate the drive letter with the truncated file name returned by GetFileInformationByHandleEx...
|
|
|
|
|
|
You asked this question a few minutes ago in Q&A. Do *NOT* cross-post.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hello Simon sorry about that this is my first post in this forum ...was just trying to get to know how and where to post...thanks
|
|
|
|
|
That's why we have guidelines everywhere (here[^] for example) which explain the rules; please read them.
It's time for a new signature.
|
|
|
|
|
Hi guys i have a new kind of error , i never seen before . Error Message is - Cannot update Program database "e:\ganesh_projects\Framework\Framework\debug\vc90.pdp . I am a fresher so any one tell what the problem is ?
|
|
|
|
|
Clean / rebuild, and you will most likely be fine.
|
|
|
|
|
As you know, if the call to LoadLibrary specifies a DLL module already mapped into the address space of the calling process, the function simply returns a handle of the DLL and increments the module's reference count.
Somewhere, I need to get the reference count od a dll. How to get the dll's reference count? Thanks.
|
|
|
|
|
|
|
well, did you try it? what was the outcome?
|
|
|
|
|
I am trying to convert float to text.
the reason i am doing this is because the float contains 0.09999987 and i want that variable as 0.10 and then compare it to other float which is initially 0.10000
if anyone have idea how to convert float to text let me know
thx,
cheers from Canada.
|
|
|
|
|
|
You should not be trying to do this; float/double values are inherently imprecise so two variables which nominally contain the same value will not necessarily be exactly the same. This is due to the binary representation of floating point numbers. There are many papers on the internet including this one[^] that deal with it.
It's time for a new signature.
|
|
|
|
|
You need to compare the difference to some epsilon. Check float.h for DBL_EPSILON or FLT_EPSILON .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
thx all for your support..
nvm it i solved it ..stupid ME ...
just added this method:
bool classname::isStringEquals(float fNewNumber,float fOldNumber)
{
CString value1;
CString value2;
value1.Format( _T("%.4f"), fNewNumber);
value2.Format( _T("%.4f"), fOldNumber);
if(value1==value2)
return true;
else
return false;
cheers from canada
|
|
|
|
|