Recent

Author Topic: Pointer and/xor set failure  (Read 428 times)

d2010

  • Full Member
  • ***
  • Posts: 121
Pointer and/xor set failure
« on: February 05, 2025, 11:58:25 pm »
I need replace the lines asm..end with PurePascal;
because the VirtualPascal not accept value of "Cardinal"
RangeChecking Error.
Many times the value of AttrCol is $FFFFFFF .
How to set AttrCol:=AttrCol and $3FFFFFFF?


Function vla_file_compressed2(Const Name:string):shortstring;
Code: [Select]
Var AttrCol: pchar;
    cow:__pin32;
    dwg:integer;
    rtcan:boolean;
begin cow.int:=0;
      cow.asc[0]:='2';
      attrcol:=nil;
      result:='';
      rtcan:=false;
      if (Name='') then Begin cow.asc:='0nil';exit;end;
  Try   AttrCol := Pointer(GetFileAttributes(PChar(Name)));
       rtcan:=pointer(AttrCol)=pointer(kINVALID_FILE_ATTRIBUTES);
      asm mov eax,AttrCol
          and eax,$3FFFFFFF
          mov AttrCol,Eax
          mov cow.int,Eax
      End;
  Except
      cow.asc[0]:=#10;
      result:=inttohex(cow.int,8);
      exit;
  End;

  if rtcan then  Begin result:='1ifa';exit;end;

  if (cow.asc[0]=' ')and (rtcan=false) then
   Begin  if (Cow.int and faDirectory  <> 0) then result:='d' else result:='f';
          if (Cow.int and faTemporary <> 0)  then result:=concat(result,'temp+');
          if (Cow.int and faOffline <> 0) then result:=concat(result,'offline+') else
          if (Cow.int and faDevice <> 0) then result:=concat(result,'device+') else
          if (Cow.int and faVirtual <> 0) then result:=concat(result,'virtual+') else
          if (Cow.int and faSparseFile <> 0) then begin result:=concat(result,'sparsefile+');
           end else
          if (Cow.int and faReparsePoint <> 0) then result:=concat(result,'sparsepoint+') else
          if (Cow.int and faCompressed <> 0) then result:=concat(result,'compressed+') else
          if (Cow.int and faNormal <> 0) then result:=concat('norm+',result);
          if ((Cow.int and faHidden) = faHidden) then result:=concat('hidden+',result);
          if ((Cow.int and faReadOnly) = faReadOnly) then result:=concat('readonly+',result);
   End;
end;

BrunoK

  • Hero Member
  • *****
  • Posts: 687
  • Retired programmer
Re: Pointer and/xor set failure
« Reply #1 on: February 06, 2025, 12:41:51 pm »
Code: Pascal  [Select][+][-]
  1. function vla_file_compressed2(const Name: string): shortstring;
  2. var
  3.   AttrCol: pchar;
  4.   cow: __pin32;
  5.   dwg: integer;
  6.   rtcan: boolean;
  7.   lEax: DWord;
  8. begin
  9.   cow.int := 0;
  10.   cow.asc[0] := '2';
  11.   attrcol := nil;
  12.   Result := '';
  13.   rtcan := False;
  14.   if (Name = '') then begin
  15.     cow.asc := '0nil';
  16.     exit;
  17.   end;
  18.   try
  19.     AttrCol := Pointer(GetFileAttributes(PChar(Name)));
  20.     rtcan := pointer(AttrCol) = pointer(kINVALID_FILE_ATTRIBUTES);
  21.     // asm
  22.     lEax := AttrCol and $3FFFFFFF; // MOV     EAX,AttrCol
  23.                                    // AND     EAX,$3FFFFFFF
  24.     AttrCol := lEax;               // MOV     AttrCol,EAX
  25.     cow.int := lEax;               // MOV     cow.int,EAX
  26.     // end;
  27.   except
  28.     cow.asc[0] := #10;
  29.     Result := inttohex(cow.int, 8);
  30.     exit;
  31.   end;
  32.  
  33. etc ...

As a side note :
- Could you please include pascal code between tags using # button you find above the message text box.
- If possible, submit code with reasonable formatting. This you can do by adding (if not already done) the package jcfidelazarus to your lazarus and Ctrl+D (or Menu/Source/JEDI code format).
 

 

TinyPortal © 2005-2018