UDRes Userlibrary (Userdefined Resources use and compile)

Developed or developing a new product in PureBasic? Tell the world about it.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

...
Last edited by ricardo on Tue Jan 30, 2007 3:03 am, edited 1 time in total.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post 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?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

SFSxOI wrote: resources including all the functions in the .dll?
for functions:

Code: Select all

UDRes_GetFunction() 
UDRes_GetPackFunction() 
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
tomijan
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Dec 11, 2005 1:32 pm

Post 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]
registered user
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update for compatible with PB4.30 (x86 only)
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Padraig
User
User
Posts: 29
Joined: Fri Jul 13, 2007 1:22 pm

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post 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 :)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post by ts-soft »

after harddisk crash i have no source for this lib.
you can use PureDataConverter
Padraig
User
User
Posts: 29
Joined: Fri Jul 13, 2007 1:22 pm

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post 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!
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post 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.
Padraig
User
User
Posts: 29
Joined: Fri Jul 13, 2007 1:22 pm

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post 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.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post by ts-soft »

I have make a small example with all required files to include a 32-bit dll here.

greetings
Thomas
Padraig
User
User
Posts: 29
Joined: Fri Jul 13, 2007 1:22 pm

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post by Padraig »

Mate, you are my hero. Thank you so so much!

Cheers,
Pad :)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: UDRes Userlibrary (Userdefined Resources use and compile)

Post by srod »

ts-soft wrote:after harddisk crash i have no source for this lib.
you can use PureDataConverter
Tut tut, no backups! :)
I may look like a mule, but I'm not a complete ass.
Pureabc
User
User
Posts: 76
Joined: Mon Jan 16, 2006 1:11 am

Re: UDRes Userlibrary (Userdefined Resources use and compile

Post 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 ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: UDRes Userlibrary (Userdefined Resources use and compile

Post 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
Post Reply