|
Looks like that this is bug in visual studio debugger
This strange symbols are nothing else than the pointer to the "cool" string in your resource section(.rdata usually) of executable. In debugger window you see destination buffer address decremented by 4 bytes. I don't know why this happens, but I think that this is bug.
|
|
|
|
|
I am creating a service along with a sys file to aid me in writing to the parallel port data byte. Iam using the code segement given below.
Ser = CreateService (Mgr,
"hwinterface",
"hwinterface",
SERVICE_ALL_ACCESS,
SERVICE_KERNEL_DRIVER,
SERVICE_SYSTEM_START,
SERVICE_ERROR_NORMAL,
"System32\\Drivers\\hwinterface.sys",
NULL,
NULL,
NULL,
NULL,
NULL
);
How ever if i change the term "hwinterface" to say "mydriver". It stops working neither does the sys file get created nor does it interface with the port. Furthermore, the Description of the file is set as buzz driver and copyright is to Buzz corporation why is this happening and how do i change the service name and its associated attributes to say Description: "My ParallelPortDriver"
Copyright to "MYcompany".
any help in this regard would be great.
sharath
|
|
|
|
|
Sharath86 wrote: if i change the term "hwinterface" to say "mydriver". It stops working neither does the sys file get created nor does it interface with the port.
The "service name" (the argument for CreateService API) should match the Symbolic Link Name registered from somewhere in AddDevice in the driver.
The reason for the above is because it (CreateService) creates a link. A link must have a concrete destination (aka in the driver).
On the other hand, the "display name" argument for CreateService API can have a different name.
Maxwell Chen
|
|
|
|
|
Hi Guys,
I have this exam on Data Structures in C. I need some help wiht Binary Trees. I found the follwing code for Binary Tree Traversal abnd its perfect. It's a recursive implementattion. I need a non recursive version too. Could someone tell me where I coulfd find it.
<br />
<br />
<br />
void Pre_order (struct NODE *Node)<br />
{<br />
if (Node)<br />
{<br />
printf(" %c", Node->Info);<br />
Pre_order(Node->Left_Child);<br />
Pre_order(Node->Right_Child);<br />
}<br />
}<br />
<br />
<br />
<br />
void In_order (struct NODE *Node)<br />
{<br />
if (Node)<br />
{<br />
In_order(Node->Left_Child);<br />
printf(" %c", Node->Info);<br />
In_order(Node->Right_Child);<br />
}<br />
}<br />
<br />
<br />
<br />
void Post_order (struct NODE *Node)<br />
{<br />
if (Node)<br />
{<br />
Post_order(Node->Left_Child);<br />
Post_order(Node->Right_Child);<br />
printf(" %c", Node->Info);<br />
}<br />
}<br />
|
|
|
|
|
Non-recursive traversals use a stack similar to the following (going off memory here, so it may not be exact):
<br />
void traverse (struct NODE *Node)<br />
{<br />
stack<NODE*> travStack;<br />
NODE* cur = Node;<br />
while (NULL != cur)<br />
{<br />
travStack.push(cur);<br />
printf(" %c", cur->Info);
cur = cur->Left_Child;<br />
printf(" %c", cur->Info);
while (NULL == cur && FALSE == travStack.empty())<br />
{<br />
cur = travStack.pop();<br />
cur = cur->Right_Child;<br />
}<br />
printf(" %c", cur->Info);
}<br />
}<br />
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
Hi,
I have some problems with managed Strings as function parameter.
See:
void f(int& x, String* s)
{
x=10;
s="hello"
return;
}
.....
String *s ="start";
int x= 0;
f(x,s);
....
Problem:
s doesn't get the new vale "hello"
is it possible to use a managed String in a function by reference ??
Thx
|
|
|
|
|
|
Hi all
Please help, I have next code :
I am building in Unicode
TCHAR array[100];
CString strText = _T("Cool");
_tcscpy_s(array,
sizeof(array),
strText
)
But the program halts and hangs, when performs _tcscpy_s method.
thank you
-- modified at 11:16 Friday 2nd June, 2006
|
|
|
|
|
There's no problem in the snippet of code you have shown. The error, presumably, lies elsewhere.
Regards,
Nish
|
|
|
|
|
big_denny_200 wrote: But the program halts and hangs, when performs _tcscpy_s method.
How are you verifying this?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Since _tcscpy_s is expanded to wcscpy_s call in Unicode version, you must specify the size of destination buffer in 2-byte unicode characters, not in bytes. Universal solution can look like this:
_tcscpy_s(array,
sizeof(array) / sizeof(TCHAR),
strText);
You got halts even if the source string was short enought, because -- in Debug version -- this function fills the buffer with 0xFD value.
-- modified at 11:33 Friday 2nd June, 2006
|
|
|
|
|
Try explicitly casting the CString object:
<br />
TCHAR array[100];<br />
<br />
CString strText = _T("Cool");<br />
<br />
_tcscpy_s(array,
sizeof(array),
(LPCTSTR)strText
);<br />
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
(Actually, explicit casting from CString to LPCTSTR is not required even in printf -like calls -- at least in VS 6.0).
|
|
|
|
|
Could you be more explicit ?
MSDN says, that second parameter of wcscpy_s must specify size of destination buffer in bytes, therefore in Unicode build destination size will be 100 * sizeof(TCHAR) (which is equal to sizeof(array) ), but in you case it will be 100(which is not the size of destination buffer)
I am little confused.
thanks
-- modified at 12:02 Friday 2nd June, 2006
|
|
|
|
|
It shouldn't be, but I've run into problems with it converting (implicitly) to char* instead of wchar_t* when I didn't explicitly cast it.
Looking back at the code again, I think he will run into another problem though. In non-UNICODE builds, he shouldn't notice anything, but in UNICODE builds, the sizeof(array) will actually return twice the size of the actual buffer. I believe the wstcpy_s function requires array size in elements, not bytes (I'll have to double-check that though). If I'm correct, he would just need to change that line from sizeof(array) to sizeof(array) / sizeof(TCHAR) .
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
What is happening ? I am replying to Viorel Bejan and this post gooes in reply to Zac Howland's post
Viorel Bejan wrote: Since _tcscpy_s is expanded to wcscpy_s call in Unicode version, you must specify the size of destination buffer in 2-byte unicode characters, not in bytes. Universal solution can look like this:
_tcscpy_s(array,
sizeof(array) / sizeof(TCHAR),
strText);
You got halts even if the source string was short enought, because -- in Debug version -- this function fills the buffer with 0xFD value.
Could you be more explicit ?
MSDN says, that second parameter of wcscpy_s must specify size of destination buffer in bytes, therefore in Unicode build destination size will be 100 * sizeof(TCHAR) (which is equal to sizeof(array) ), but in you case it will be 100(which is not the size of destination buffer)
I am little confused.
thanks
-- modified at 12:02 Friday 2nd June, 2006
-- modified at 12:04 Friday 2nd June, 2006
|
|
|
|
|
Actually, it says the second parameter of wcscpy_s must specify size of destination buffer in words (in bytes for non-Unicode). Thus, it is the size in characters and not size in bytes! If you are using a statically-allocated array as a destination, you can use the _countof macro instead of sizeof. However, sizeof(array) / sizeof(TCHAR) also returns the correct size.
|
|
|
|
|
thanks, I did not pay attention to the WORD
|
|
|
|
|
Word, man! 
|
|
|
|
|
Viorel Bejan wrote: You got halts even if the source string was short enought, because -- in Debug version -- this function fills the buffer with 0xFD value.
But in this specific case, it's not bad enough to cause a halt - since he has a 100 byte buffer and a 5 character string.
Regards,
Nish
|
|
|
|
|
big_denny_200 wrote: But the program halts and hangs, when performs _tcscpy_s method.
(Offtopic sarcasm)
Glad to see these "safe" functions in action.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
Nemanja Trifunovic wrote: (Offtopic sarcasm)
Glad to see these "safe" functions in action.
Regards,
Nish
|
|
|
|
|
According to:
http://msdn2.microsoft.com/en-us/library/td1esda9.aspx[^]
the sizeof(array) should correspond to the number of 'characters' - not 'bytes'.
So - in case of ANSI, it's bytes. In case of unicode, it's words (2-bytes).
When the code you listed compiles for unicode, sizeof(array) is 200 - which is double the actual number of characters.
Note that _tcscpy_s() zeros out the buffer after copying... and that's when you get the buffer overrun. You can find that out by stepping into _tcscppy().
You can use (sizeof(array)/sizeof(array[0])) or the _countof() macro.
gmileka
|
|
|
|
|
I am using Visual Studio C++.NET
I am familiar with creating dialog applications. But i want to include menus
However, i would like to create a windows application with menu options, file etc.. and at the same time, include controls like buttons drop down boxes, picture control area. Can anyone direct me to a good tutorial or if you can explain some basic steps i'd be grateful... I know that it should be easy, i just don't know where to start...
Thanks,
|
|
|
|