Thema: Delphi Stack überlauf

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#1

Stack überlauf

  Alt 6. Aug 2017, 21:53
Zitat:
exception class : EStackOverflow
exception message : Stack-Überlauf.

main thread ($1894):
05e40d12 +012 KVideoPlayer.dll sprintf 23 +0 CallWvsprintf
05e41fb8 +088 KVideoPlayer.dll CommonUtils 131 +5 ReportError
05e428be +17e KVideoPlayer.dll CommonUtils 394 +31 BuildDirect3d
Die Funktion die das verursacht.

Delphi-Quellcode:
  hr := m_pD3DDirect3d.CreateDevice(D3DADAPTER_DEFAULT, // always the primary display adapter
                              D3DDEVTYPE_HAL,
                              0,
                              D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                              @d3dpp,
                              m_pD3DDevice);
   if (FAILED(hr)) then
     ErrStr := ReportError('Cannot create a Direct3d device', hr) // <<<< von hier geht das aus.
  else
     result := TRUE;
Delphi-Quellcode:
function ReportError(pszError: pchar; hrCode: HRESULT): WideString;
var
  szErr: array [0..MAX_ERROR_TEXT_LEN-1] of char;
  res: DWORD;

begin
   res := AMGetErrorText(hrCode, @szErr[0], MAX_ERROR_TEXT_LEN);
   if (res <> 0) then
    result := CallWvsprintf('%s : COM Error 0x%x, %s', [pszError, hrCode, szErr])
   else
    result := CallWvsprintf('%s : COM Error 0x%x', [pszError, hrCode]);
end;
die gesamte Unit.
Delphi-Quellcode:
// This unit is made using the code from following URL,
// http://proger.i-forge.net/Calling_printf_from_Delphi/7ES

unit sprintf;

interface

function CallWvsprintf(Format: WideString; const Args: array of const): WideString;

implementation

uses SysUtils, Windows;

type
  TVAList = array[0..$FFFF] of Pointer;

function CallWvsprintf(Format: WideString; const Args: array of const): WideString;
var
  VA: TVAList;
  StrI, I, Size: Integer;
  Strings: array[0..High(VA)] of WideString;

begin
  StrI := 0;
  Size := Length(Format) * 2;

  for I := 0 to Length(Args) - 1 do
    with Args[I] do
      if I >= Length(VA) then
        raise EConvertError.CreateFmt('Too many format arguments (more than %d).', [Length(VA) - 1])
        else
          case VType of
          vtInteger:
            begin
              VA[I] := Pointer(VInteger);
              Inc(Size, 20);
            end;
          vtPChar,
          vtAnsiString:
            begin
              // Delphi will automatically convert String or PChar
              // into WideString and vice versa:
              Strings[StrI] := VPChar + #0;
              VA[I] := @Strings[StrI][1];
              Inc(Size, Length(Strings[StrI]) * 2 - 2 {null-terminator});
              Inc(StrI);
            end;
          vtPWideChar,
          vtWideString:
            begin
              VA[I] := VPWideChar;
              Inc(Size, Length(VPWideChar) * 2);
            end;
          else
            raise EConvertError.CreateFmt('Invalid format argument of VType = %d.', [VType]);
          end;

  SetLength(Result, Size + Size div 10); {10% extra space}
  SetLength(Result, wvsprintfW(@Result[1], PWideChar(Format), @VA));
end;

end.
in CallWvsprintf direkt bei begin.

kann mir jemand einen Tip geben wie ich das beheben kann?
Wie man lesen kann ist die Unit nicht von mir und der Entwickler nicht mehr erreichbar.

gruss

Geändert von EWeiss ( 6. Aug 2017 um 22:12 Uhr)
  Mit Zitat antworten Zitat