|
Hello Dan,
I am rather certain I agree about the const. However, I am a bit weak on exactly where the const goes to effect which part of a declaration. For the moment, I want to keep the thread as simple as I can. I will get back to the const in another thread. Thanks for the reminder.
Thanks for your time
|
|
|
|
|
Hi,
Can I know how to perform structured exception handling in Windows Vista..
I need alternatives to Isbadreadptr,IsBadWritePtr in Windows Vista.. But Vista documentation suggests to perform Structured exception handling. Can I know how to perform Structured exception handling
Thanks,
venkat
|
|
|
|
|
Using IsBadReadPtr or Structured Exception Handling (or for that matter any other method) to detect illegal memory accesses is wrong headed in the vast majority of cases. There are many issues but here are a few:
- Makes debugging harder as an exception that would have triggered a debugger or the generation of a crash dump is swallowed. I do a lot of post-mortem debugging: when you click the “Send Error Report” button, in theory, someone will look at the dump-file which is sent and actually figure out what’s going on. If you don't use the Windows Error Reporting[^] service (or something else which performs the same task) then you're doing it wrong.
- In general proper recovery is impossible and attempting to just makes things worse. An analogy is a person who continues to drive with a flat tire.
Follow link this[^] for Larry Osterman's opinion on the matter and follow this[^] link for Raymond Chen's.
Steve
|
|
|
|
|
Thanks Steve. Can I Know what could be the better substitute for detecting illegal memory access.. Can I have a sample code snippet to get an idea.
Thanks,
Venkat
|
|
|
|
|
int* x = new int[1000];
void foo(int i)
{
if(i>0 && i<1000)
{
x[i] = 0;
}
else
{
}
}
That's it!
-Saurabh
|
|
|
|
|
As I said, in general the best substitute for detecting an illegal memory access is crashing!
Steve
|
|
|
|
|
Hi,
We have a legacy code written in C. We are porting to Windows Vista. We have certain checks like IsBadReadPtr and IsBadWritePtr. These two checks donot work in Windows-Vista. Can I know how to validate a memory block before its usage in Window-Vista... I mean what could be the appropriate replacement for IsBadReadPtr and IsBadWritePtr in Windows Vista.
Thanks,
Venkat
|
|
|
|
|
Documentation [^] suggests to substitute such a function with structured exception handling.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks.. Can I have a code snippet for performing structured exception handling..
|
|
|
|
|
Possibly documentation [^] helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Possibly documentation helps.
Not when left unread
|
|
|
|
|
Plz give code urgent plz plz.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Why not write your own.
Just set up a try/catch block and a for loop which reads each byte in the range. return true from the catch, or false if it terminates in the try block. IsBadWritePtr goes similar, just try to write the selfsame byte back to where it was read from.
Regards,
Bram van Kampen
|
|
|
|
|
Why not just crash? See here[^].
Steve
|
|
|
|
|
Hey everybody!
Does anyone know where can I find the domain controller SID in the WMI (XP) ???
Thanks!
|
|
|
|
|
Look at Win32_NTDomain class in WMI. It has among other these members.
string DomainControllerAddress;
int32 DomainControllerAddressType;
string DomainControllerName;
string DomainGUID;
string DomainName;
-Saurabh
|
|
|
|
|
Hey, Thanks for your help!
But I need SID, which is not found over there...
|
|
|
|
|
Okay, found it.
If we will take a look for at Win32_Group (it can be done in other ways, that is just one of them), all the groups that belong to the domain has the same SID prefix.
This prefix is the domain's SID!
Ta-Da!
Have Fun!
|
|
|
|
|
Great! Thanks for sharing.
-Saurabh
|
|
|
|
|
the application i am using requires the uncompressed tiff file having bit depth 1 and resolution of 300dpi. it is built in dot net 2003. whenever i open the uncompressed tiff image having bit depth 1 and save the same tiff image using savefiledialog function of dot net2003, the uncompressed tiff file becomes compressed and the bit depth is increased to 32. i haven't use any compression function. the code of saving the file is given below
private: void saveImageFile()
{
saveImage->Filter= "Tiff files (*.tif)|*.tif" ;
saveImage->FilterIndex = 1 ;
saveImage->RestoreDirectory = true ;
System::Windows::Forms::DialogResult d = this->saveImage->ShowDialog();
if (d == System::Windows::Forms::DialogResult::OK)
{
// creating a bitmap
Bitmap* saveMyImage;
saveMyImage=new Bitmap(this->pictureBox1->Image);//,System::Drawing::Imaging::PixelFormat::Format1bppIndexed);
saveMyImage->SetResolution(300,300);
saveMyImage->PixelFormat::Format1bppIndexed;// this line doesnot work
saveMyImage->Save(saveImage->FileName,System::Drawing::Imaging::ImageFormat::Tiff);
}
}
|
|
|
|
|
I think you better ask the managed C++/CLI forum [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
My lecturer require me to use char for string.
I include the string.h header file for my program.
I have a pointer variable by using the following code.
<br />
char *abc[10][10];<br />
char *def[10];<br />
After I initialize *def[], I enter the following code.
<br />
int n=0;<br />
strcpy(*abc[n],*def);<br />
After I enter the code above, my program crash. Why?
|
|
|
|
|
I really can't tell what you're trying to do with the above code - whether there's a single thing out of place, or if the whole thing is ass-about.
See, you've declared two arrays of pointers - you then start copying the strings pointed to by the pointers in the def array into the memory locations pointed to by the abc array, although you never actually allocate any memory for the string. - What does abc[0][0] point at? That's where you're trying to copy a string to. - Plainly put, you most likely don't own the memory that abc's elements are pointing at, hence the crash. - try removing the malloc statement then seeing what happens - seem familiar?
Here - some code that will hopefully do a better job of explaining this than I fear I am doing atm.
int main()
{
char *abc[10][10];
char *def[10];
int i = 0;
def[0] = "String 0";
def[1] = "String 1";
def[2] = "String 2";
def[3] = "String 3";
def[4] = "String 4";
def[5] = "String 5";
def[6] = "String 6";
def[7] = "String 7";
def[8] = "String 8";
def[9] = "String 9";
printf("Method 1 - copy strings themselves\n");
printf("----------------------------------\n");
for (i=0; i<10; i++)
{
abc[0][i] = malloc(strlen(def[i])+1);
strcpy(abc[0][i], def[i]);
}
for (i=0; i<10; i++)
{
printf("%s\n", abc[0][i]);
free(abc[0][i]);
abc[0][i] = NULL;
}
printf("\n\n");
printf("Method 2 - just copy pointers to the strings\n");
printf("--------------------------------------------\n");
for (i=0; i<10; i++)
{
abc[0][i] = def[i];
}
for (i=0; i<10; i++)
{
printf("%s\n", abc[0][i]);
}
}
|
|
|
|
|
cshong wrote: After I initialize *def[], I enter the following code.
Please post the initialization code.
BTW did you initialize abc as well?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|