Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strike>It looks to me like you're missing a couple of pointer dereferences, and therefore corrupting memory addresses. </p> <p>If I'm not mistaken, the Move() call should be:</p> <p><code> Move(Buffer^, ReceiveBuffer^, iSize); </strike></p> <p>I've removed my totally worthless post content (leaving it for posterity and to give someone a good laugh).</p> <p>I don't see anything that would be affected by Unicode at all. I'm going to edit the tags to include Delphi (without the 2009), as some of the CodeGear Delphi developers are currently posting there. Perhaps one of them can see what's happening.</p> <p>I made up a contrived example (actually a pretty useless one):</p> <pre>uses IdGlobal; type TModBusFunction = Byte; TModBusDataBuffer = array[0..256] of Byte; TCommsBuffer=packed record TransactionID: Word; ProtocolID: Word; RecLength: Word; UnitID: Byte; FunctionCode: TModBusFunction; MBPData: TModBusDataBuffer; Spare: Byte; end; procedure TForm1.FormShow(Sender: TObject); var Buffer: TIdBytes; ReceiveBuffer: TCommsBuffer; //iSize: Word; begin FillChar(ReceiveBuffer, SizeOf(ReceiveBuffer), 0); ReceiveBuffer.TransactionID := 1; ReceiveBuffer.ProtocolID := 2; ReceiveBuffer.RecLength := 3; ReceiveBuffer.UnitID := 4; ReceiveBuffer.FunctionCode := 5; FillChar(ReceiveBuffer.MBPData[0], SizeOf(ReceiveBuffer.MBPData), 6); ReceiveBuffer.Spare := 7; SetLength(Buffer, SizeOf(ReceiveBuffer)); Move(ReceiveBuffer, Buffer, SizeOf(ReceiveBuffer)); Move(Buffer, ReceiveBuffer, SizeOf(ReceiveBuffer)); ReceiveBuffer.UnitID := 8; end; </code></pre> <p>I then set a breakpoint on the last line before the end, and ran it. When the breakpoint was hit, I looked at the contents of ReceiveBuffer using ToolTip Evaluation, and everything looked perfectly fine. I could see all of the proper values, including the ReceiveBuffer.Spare being 7. I then single stepped, and looked at ReceiveBuffer.UnitID; it in fact had a value of 8. </p> <p>However, pressing F9 to continue running (expecting to be able to just close the form and end the application), I ended up in the CPU window and got a message from Vista that the application wasn't responding. I was just outside ntdll.DebugBreakPoint, IIRC, and single stepping brought me into ntdll.RtlReportException. I'm not quite sure what's happening, but it ain't good. Still looking.</p> <p>Edit2: I ran it again, with the same results. However, this time I noticed before I used Ctrl+F2 to terminate the app that Vista was giving me a popup tooltray window indicating that "Project1.exe has been closed" and mentioning DEP (which I have enabled in hardware on this machine). </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload