Page 2 of 3

Posted: Mon Jan 29, 2007 8:30 pm
by ricardo
...

Posted: Mon Jan 29, 2007 9:14 pm
by SFSxOI
ts-soft wrote:Update:
Added 2 Functions

Code: Select all

UDRes_GetModuleHandle(ResNumber.l [, hModule.l]) 
UDRes_GetPackModuleHandle(ResNumber.l [, hModule.l])
The result is the ModuleHandle. With this, you can load all resources from included DLL
resources including all the functions in the .dll?

Posted: Tue Jan 30, 2007 9:54 am
by ts-soft
SFSxOI wrote: resources including all the functions in the .dll?
for functions:

Code: Select all

UDRes_GetFunction() 
UDRes_GetPackFunction() 

Posted: Sun Oct 21, 2007 6:29 pm
by tomijan
Hi,
@TS-Soft
I try use your great library UDRes with dll compiled with MSVC2005.
When use UDRes_GetFunction, programm crash with information like
"R6034
An application has made attempt to load C runtime library incorrectly."
Any chance to get it work correctly?
tom[/img]

Posted: Sat Sep 27, 2008 4:25 pm
by ts-soft
Update for compatible with PB4.30 (x86 only)

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 9:39 pm
by Padraig
Hello!

Any chance for an update of this library for PB4.41? Tested the old one, it's truly great and it would be so handy for one of my planned progs. I want to develop this in the newest PB version though, which isn't compatible with UDRes :(

Pad :)

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 10:09 pm
by ts-soft
after harddisk crash i have no source for this lib.
you can use PureDataConverter

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 10:44 pm
by Padraig
Aww too bad. I was especially after the easy DLL include, which was so damn handy. I'll have a look at PureDataConverter and see if I can get it to work with that. Thanks for the quick response!

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 10:49 pm
by ts-soft
You can include a DLL but the functions to using not included. I can give you a static lib,
created from memorymodule and a includefile for using, if required.

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 11:00 pm
by Padraig
Thanks for the kind offer, I'll get back at you if I can't get it to work, which I most definiteIy probably won't! :lol: I can't test anything at the moment since I'm not at home.

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 11:12 pm
by ts-soft
I have make a small example with all required files to include a 32-bit dll here.

greetings
Thomas

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Fri Mar 19, 2010 11:17 pm
by Padraig
Mate, you are my hero. Thank you so so much!

Cheers,
Pad :)

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Posted: Sat Mar 20, 2010 11:41 am
by srod
ts-soft wrote:after harddisk crash i have no source for this lib.
you can use PureDataConverter
Tut tut, no backups! :)

Re: UDRes Userlibrary (Userdefined Resources use and compile

Posted: Wed Jun 02, 2010 8:39 pm
by Pureabc
ts-soft wrote:I have make a small example with all required files to include a 32-bit dll here.

greetings
Thomas
I tried to modify the example by changing the dll.

How do you generate the .res file ?

Re: UDRes Userlibrary (Userdefined Resources use and compile

Posted: Wed Jun 02, 2010 9:05 pm
by ts-soft
Pureabc wrote:How do you generate the .res file ?

Code: Select all

CompilerIf Defined(compress2, #PB_Procedure) = #False
ImportC "zlib.lib"
  compress2(*dest, *destLen, *source, sourceLen, level)
EndImport
CompilerEndIf

Enumeration
  #UDRes_Packer_None
  #UDRes_Packer_jCalg1
  #UDRes_Packer_zip
EndEnumeration

CompilerIf Defined(UDResPack, #PB_Structure) = #False
Structure UDResPack
  Size.q
  CRC.q
  Packer.b
  Magic.b[6]
EndStructure
CompilerEndIf

CompilerIf Defined(_PackMemory, #PB_Procedure) = #False
Procedure _PackMemory(*SourceMemoryID, SourceLength, *DestionationMemoryID, DestLength, Level = 9, Packer = #UDRes_Packer_jCalg1)

  Select Packer
    Case #UDRes_Packer_jCalg1
      ProcedureReturn PackMemory(*SourceMemoryID, *DestionationMemoryID, SourceLength, Level)
    Case #UDRes_Packer_zip
      If Not compress2(*DestionationMemoryID, @DestLength, *SourceMemoryID, MemorySize(*SourceMemoryID), Level)
        ProcedureReturn DestLength
      EndIf
  EndSelect
  
EndProcedure
CompilerEndIf

Procedure UDRes_Create(ResFileName.s)
  Protected FileID

  FileID = CreateFile(#PB_Any, ResFileName)
  If FileID
    WriteLong(FileID, 0)
    WriteLong(FileID, 32)
    WriteLong(FileID, 65535)
    WriteLong(FileID, 65535)
    WriteLong(FileID, 0)
    WriteLong(FileID, 0)
    WriteLong(FileID, 0)
    WriteLong(FileID, 0)
    ProcedureReturn FileID
  EndIf
EndProcedure

Procedure UDRes_Open(ResFileName.s)
  Protected FileID

  FileID = OpenFile(#PB_Any, ResFileName)
  If FileID
    FileSeek(FileID, Lof(FileID))
    ProcedureReturn FileID
  EndIf
EndProcedure

Procedure UDRes_Close(FileID)
  ProcedureReturn CloseFile(FileID)
EndProcedure

Procedure UDRes_AddMem(FileID, *MemoryID, ResNumber, Packer = 0)
  Protected DataSize, I, Mod
  Protected *DestMEM.UDResPack
  Protected Size, NewSize

  If IsFile(FileID) = #False : ProcedureReturn #False : EndIf
  If ResNumber < 1 : ProcedureReturn #False : EndIf
  
  If Packer
    If *MemoryID
      Size = MemorySize(*MemoryID)
      If Size
        *DestMEM = AllocateMemory(Size + (SizeOf(UDResPack) + 12 + (Int(Size / 100) + 1)))

        If *DestMEM
          *DestMEM\Size = Size
          *DestMEM\CRC = CRC32Fingerprint(*MemoryID, Size)
          *DestMEM\Packer = Packer
          *DestMEM\Magic[0] = 'P'
          *DestMEM\Magic[1] = 'B'
          *DestMEM\Magic[2] = 'D'
          *DestMEM\Magic[3] = 'A'
          *DestMEM\Magic[4] = 'T'
          *DestMEM\Magic[5] = 'A'

          NewSize = _PackMemory(*MemoryID, Size, *DestMEM + SizeOf(UDResPack), MemorySize(*DestMEM), 9, *DestMEM\Packer)

          If NewSize
            *DestMEM = ReAllocateMemory(*DestMEM, NewSize + SizeOf(UDResPack))
            FreeMemory(*MemoryID)
            *MemoryID = *DestMem
          Else
            FreeMemory(*DestMEM)
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf

  If *MemoryID And MemorySize(*MemoryID) > 0
    DataSize = MemorySize(*MemoryID)

    WriteLong(FileID, DataSize)
    WriteLong(FileID, 44)

    WriteWord(FileID, 'P')
    WriteWord(FileID, 'B')
    WriteWord(FileID, 'D')
    WriteWord(FileID, 'A')
    WriteWord(FileID, 'T')
    WriteWord(FileID, 'A')
    WriteWord(FileID, 0)

    WriteWord(FileID, $FFFF)
    WriteWord(FileID, ResNumber)

    For I = 1 To 4
      WriteLong(FileID, 0)
    Next
    WriteWord(FileID, 0)

    WriteData(FileID, *MemoryID, DataSize)
    Mod = DataSize % 4
    If Mod
      Select Mod
        Case 1 : WriteWord(FileID, 0) : WriteByte(FileID, 0)
        Case 2 : WriteWord(FileID, 0)
        Case 3 : WriteByte(FileID, 0)
      EndSelect
    EndIf
    
    FreeMemory(*MemoryID)
    
    ProcedureReturn #True
  EndIf
EndProcedure

Procedure UDRes_AddFile(FileID, FileName.s, ResNumber, Packer = 0)
  Protected FileR, Size
  Protected *Mem

  FileR = ReadFile(#PB_Any, FileName)
  If FileR
    Size = Lof(FileR)
    *Mem = AllocateMemory(Size)
    If *Mem
      ReadData(FileR, *Mem, Size)
      CloseFile(FileR)
      ProcedureReturn UDRes_AddMem(FileID, *Mem, ResNumber, Packer)
    EndIf
    CloseFile(FileR)
  EndIf
EndProcedure