+ wideStringLength = lstrlenW(wideString); + sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, wideString, wideStringLength, NULL, 0, NULL, NULL); + + if (sizeNeeded < 0) + { + return NULL; + } + + newString = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeNeeded + 1); + WideCharToMultiByte(CP_UTF8, 0, wideString, wideStringLength, newString, sizeNeeded, NULL, NULL);
This would be much simpler if you passed in -1 as the wide string length. Using HEAP_ZERO_MEMORY to null-terminate the string is a bit weird.
+ else if (curNode->Type == TextType) + { + textNode = WSDAllocateLinkedMemory(parent, sizeof(WSDXML_TEXT)); + if (textNode == NULL) goto cleanup; + + textNode->Node.Next = NULL; + textNode->Node.Parent = parent; + textNode->Node.Type = TextType; + textNode->Text = duplicate_string(textNode, ((WSDXML_TEXT *)curNode)->Text); + if (textNode->Text == NULL) goto cleanup; + }
I'm not sure, but I think you need to add textNode as a child of newElement?
+ /* SequenceID attribute */ + if (header->AppSequence->SequenceId != NULL) + { + if (!add_string_attribute(xmlContext, appSequenceElement, discoveryNsUri, sequenceIdString, header->AppSequence->SequenceId)) goto cleanup; + }
Do we need the namespace for SequenceID?
On 28/07/2017 21:00, Vincent Povirk wrote:
This would be much simpler if you passed in -1 as the wide string length. Using HEAP_ZERO_MEMORY to null-terminate the string is a bit weird.
I'll amend that, thanks.
I'm not sure, but I think you need to add textNode as a child of
newElement?
It gets added as a child of "parent" (which "newElement" is also a child of). It would be more consistent to attach it to "newElement" though, I'll change that.
Do we need the namespace for SequenceID?
The namespace needs to be passed in, but it won't appear in the generated message, as per:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb513682(v=vs.85).a...
Cheers,
Do we need the namespace for SequenceID?
The namespace needs to be passed in, but it won't appear in the generated message, as per:
https://msdn.microsoft.com/en-us/library/windows/desktop/bb513682(v=vs.85).a...
Is there something special about SequenceId compared to InstanceId and MessageNumber?
On 31/07/2017 21:50, Vincent Povirk wrote:
Is there something special about SequenceId compared to InstanceId and MessageNumber?
Hm, no, and it looks like it does work correctly without the namespace being passed in.