添加以下德尔福功能后,我收到有关数据类型错位的错误:Project ... faulted with message: 'datatype misalignment at 0x77a7d7d8'. Process Stopped. Use Step or Run to continue.
德尔福的数据类型错位?
我添加的功能如下。请注意,该函数实际上成功完成,但只有时间戳实际写入文件。
procedure Log(msg : String);
var
tempFolderChars : array [0..MAX_PATH] of Char;
tempFolder : string;
logFile : TextFile;
dt : TDateTime;
begin
GetTempPath(SizeOf(tempFolderChars), tempFolderChars);
tempFolder := IncludeTrailingPathDelimiter(String(tempFolderChars));
dt := Now();
AssignFile(logFile, tempFolder + 'GenericHolding.txt');
if FileExists(tempFolder + 'GenericHolding.txt') then
Append(logFile)
else
ReWrite(logFile);
Write(logFile, FormatDateTime('yyyy-mm-dd hh:nn:ss ', now));
Write(logFile, msg);
Write(logFile, #13, #10);
CloseFile(logFile);
end;
编辑:增加更多组件的输出。
ntdll.NtQueryInformationProcess:
77BAFAC8 B816000000 mov eax,$00000016
77BAFACD 33C9 xor ecx,ecx
77BAFACF 8D542404 lea edx,[esp+$04]
77BAFAD3 64FF15C0000000 call dword ptr fs:[$000000c0]
77BAFADA 83C404 add esp,$04
77BAFADD C21400 ret $0014
能否请您发布的内容是在地址'0x77a7d7d8'?也许堆栈跟踪? –
我无法使用您的代码重现您的问题(复制/直接粘贴到D2007项目中)。你使用的是什么Delphi版本和操作系统? –
IIRC,Delphi的版本非常重要,因为简单的类型转换并不总是有效。在旧版Delphi中,您需要使用StrPas。另一个有用的信息是你传递的msg的内容。 – Graymatter