|
Hi there,
I have noticed when I debug a win32 C++ application, often I see a lot of .dll are loaded some which are required some which are not. One of the dlls loaded tend to crash my application, such as nl_lsp.dll from NetLimiter. Well, I need to use netlimiter from time to time, but the library was neither use nor included in my code, so how's that possible in the first place?
Can anyone shed some light regarding what happens at runtime when you debug an application using Visual Studio? Is this a VS problem or just my computer. Is there a way to exclude or prevent the dll from loading into my application. Thanks.
I'm using Windows XP Professional with SP2, VS2005 MDE with SP1
|
|
|
|
|
Some DLL's will be loaded into the address space of all applications, whether they are needed or not.
You may find that this is the case with th NetLimiter dll, but it should not be crashing your application unless it's injected a thread into your code or trying to hook something.
It's not a problem with either VS or your computer, its a feature of Windows, and is used by many windows dll's such as kernel32.dll
regards,
|
|
|
|
|
You may not need the DLLs but some DLL your app links to is linking to other DLLs.
If some DLL in your app's address space is truly causing a crash, and it's not a DLL that you explicitly link to or load, then
IMO your system is unstable. Uninstall the offending software, reinstall Windows, whatever.
IME this is rarely the case...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
nl_lsp.dll is probably a Layered Service Provider.... essentially a winsock function hook to intercept network function calls. These types of DLL's are mapped into your application space automatically. More about LSP: http://www.microsoft.com/msj/0599/LayeredService/LayeredService.aspx[^]
Yes, It is possible to restore the winsock chain to its original state while your application is running and when your application exits, restore the LSP chain.
This application is designed to restore winsock2 to its original state: http://cexx.org/lspfix.htm[^]
It comes with source code, which is essentially modifying the registry...
Good Luck.
-Randor (David Delaune)
|
|
|
|
|
Hello,
How do i convert an ascii of 10bytes(09090909090909090909) to a hex of 5 bytes 0x2540BE3FF, any sample appreciated.
|
|
|
|
|
|
Let me rephrase my question,
I have a byte array,
BYTE* m_baPersonImage = new BYTE[10];
m_baPersonImage[1] =07;
m_baPersonImage[2] =07;
m_baPersonImage[3] =07;
m_baPersonImage[4] =07;
m_baPersonImage[5] =07;
m_baPersonImage[6] =07;
m_baPersonImage[7] =07;
m_baPersonImage[8] =07;
m_baPersonImage[9] =07;
m_baPersonImage[10] =07;
I need to convert this 10 byte array to hex of 5 bytes. i tried _atoi64 but does not seem to work.
With Rgds,
|
|
|
|
|
AnilUnni wrote: m_baPersonImage[10] =07;
Out of boundary.
AnilUnni wrote: I need to convert this 10 byte array to hex of 5 bytes
You can convert your 10-bytes array into a a 5 bytes one (binary not hex,
hex is only a convenient numerical base) if and only if you're sure each byte of the original array ranges from 0 to 15 (as in your example).
If the above is your requirement then
BYTE target[5];
target[0] = m_baPersonImage[0] * 16 + m_baPersonImage[1];
target[1] = m_baPersonImage[2] * 16 + m_baPersonImage[3];
...
Hope that 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.
|
|
|
|
|
1) How many times are you going to ask this before you try something?
2) WHY would you store a number like this?
3) If you want us to write the code, please provide enough info. You called these "hexa format". Does this mean they can
go to FF or is 09 the largest "digit"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
for the first question,I am trying things.
for the second question, this is how it is stored in the database. If i had to change the implementation of how it is stored then I should be rewriting the entire stuff of storing in the hexa format which does not seem to be feasible
for the last question, the largest cannot be more than 09, meaning if i enter 9999999999 which is the largest number i can enter, then it is stored as 09090909090909090909 in the database, when i send it through the wire i should convert it into a hex of 5 bytes
With Rgds
|
|
|
|
|
TCHAR szSource[] = _T("09090909090909090909");
TCHAR szSourceFormatted[11];
for (int i = 0; i < 10; ++i)
szSourceFormatted[i] = szSource[i*2+1];
szSourceFormatted[10] = _T('\0');
__int64 llValue = _tstoi64(szSourceFormatted);
unsigned char BytesToSend[5];
BytesToSend[0] = (unsigned char)(llValue >> 32);
BytesToSend[1] = (unsigned char)(llValue >> 24);
BytesToSend[2] = (unsigned char)(llValue >> 16);
BytesToSend[3] = (unsigned char)(llValue >> 8);
BytesToSend[4] = (unsigned char)(llValue);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
simple answer : no way.
you cannot store an integer which is 10 bytes wide into 5 bytes...
hexadecimal is just a matter of representation of a number, such as decimal, octal, and binary...
your number in memory will be stored with 1s and 0s...
|
|
|
|
|
Hi all,
i am writing code to create XML file which looks like this:
<code><rtcs name="Remote Target Control System">
<connection connect="Server" ipaddress="" port="27015">
<logging directory="C:\RTCSLogs\log1.log" level="5" comport="27016" maxsize="1">
<ir directory_path="C:\signalDB.xml">
To accomplish above i have created code like this:
HRESULT hr;
IXMLDOMDocument2Ptr pXMLDoc = NULL;
CoInitialize(NULL);
hr=pXMLDoc.CreateInstance("DOMDocument.4.0");
MSXML2::IXMLDOMNodePtr pRootNode= NULL;
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
pRootNode= pXMLDoc->createNode(varNodeType,
_T("RTCS"), _T("Remote Target Control System"));
pXMLDoc->appendChild(pRootNode);
MSXML2::IXMLDOMNodePtr pRecNode= NULL;
pRecNode = pRootNode->appendChild(pXMLDoc->createElement(_T("Connection")));
MSXML2::IXMLDOMAttributePtr pRecIdAttr = NULL;
pRecIdAttr = pXMLDoc->createAttribute(_T("connect"));
pRecIdAttr->nodeTypedValue = _T("connect_val");
pRecNode->attributes->setNamedItem(pRecIdAttr);
MSXML2::IXMLDOMAttributePtr pRecIdAttr1 = NULL;
pRecIdAttr1 = pXMLDoc->createAttribute(_T("ipaddress"));
pRecIdAttr1->nodeTypedValue = _T("ip_address");
pRecNode->attributes->setNamedItem(pRecIdAttr1);
But the above code works good in MSXML2 but i want to work in MSXML4
and so i am modifying code so that it works fine in MSXML4: which is as follows:
XMLDOMDocumentPtr pXMLDoc = NULL;
CoInitialize(NULL);
hr=pXMLDoc.CreateInstance("msxml2.domdocument");
IXMLDOMNodePtr pRootNode= NULL;
IXMLDOMNodePtr pRecNode= NULL;
_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);
hr= pXMLDoc->createNode(varNodeType,
_T("RTCS"), _T("Remote Target Control System"),&pRootNode)
but the problem is with i am not able to attach child node Connection with Root node RTCS:
I am not able to get the code right for the above version to do this.
The problem is CreateElementdoesn't work same in both the versions,also attributes is also different.
Regards
|
|
|
|
|
Maynka wrote: The problem is CreateElementdoesn't work
I used MSXML4 some time ago to do stuff like this and it always worked correctly.
<br />
hr= pXMLDoc->createNode(varNodeType,<br />
_T("RTCS"), _T("Remote Target Control System"),&pRootNode)
Did you evaluate the HRESULT? What is it?
Why aren't you using the ATL wrapper classes that #import will generate for you?
|
|
|
|
|
Hi all,
i want to create an XML file with root node RTCS having value remote.
Then i want to create child node of this named Connection:
which has elements:
1. Connect ,value:connect_val
2. Port,value:port_number.
actually i am able to create xml file but it is having root node and its value only:
like this:
<rtcs xmlns="Remote Target Control System">
but i am not able the attach child node Connection to this root.
Any help is highly appreciated.
Regards
|
|
|
|
|
Hello everyone,
The 3rd parameter of WriteFile is number of bytes to write,
http://msdn2.microsoft.com/en-us/library/aa365747.aspx
I am wondering if I want to write multi-byte character string or wide character string on Windows, how could I get the number of bytes?
thanks in advance,
George
|
|
|
|
|
George_George wrote:
I am wondering if I want to write multi-byte character string or wide character string on Windows, how could I get the number of bytes?
_tcslen(str) * sizeof(TCHAR)
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: _tcslen(str) * sizeof(TCHAR)
I wonder if the above expression correctly addresses multibyte strings (see [^]).
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.
|
|
|
|
|
CPallini wrote: I wonder if the above expression correctly addresses multibyte strings
Why wouldn't it?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: Why wouldn't it?
No more objections. You're right (maybe I found something [^] clearifying your point... )
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.
|
|
|
|
|
|
Basically, I want to convert a DWORD to a LPCSTR for use in an edit box, but I don't really know how to go about this. If I can do this with an API function, that would be recommended.
|
|
|
|
|
char buf[20];
sprintf(buf, "%u", myDWORD);
|
|
|
|
|
boost::lexical_cast[^], which basically is a convenience wrapper around std::stringstream or itoa if you fell like using plain old C.
Failure is not an option - it's built right in.
|
|
|
|
|
Do you mean:"I want to show the string representation of a DWORD content in a edit box?"
If the answer is yes Then:
DWORD dwValue = ...;
CHAR buffer[34];
ltoa(dwValue, buffer, 10);
SendMessage(hWndEdit, WM_SETTEXT, (WPARAM)0, (LPARAM) buffer)
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.
|
|
|
|