Author Topic: Resource dll not made by powerbasic  (Read 3287 times)

0 Members and 1 Guest are viewing this topic.

Offline Paul Breen

  • Newbie
  • *
  • Posts: 39
  • User-Rate: +1/-10
Resource dll not made by powerbasic
« on: November 24, 2009, 07:29:21 PM »
I guess I had upgrade fever or something, I don't know but I upgraded my Resource Builder to version3, which can make "resource only" dll's that are "standard win32 dll's" that can be use by programs written in any language. This program generates the rc file from the design that you make using a GUI.
How to I make calls to this dll? Is anybody else using Resource Builder as their res compiler?
thanks,

Offline Norbert Doerre

  • Newbie
  • *
  • Posts: 7
  • User-Rate: +1/-5
    • mechanicad
Re: Resource dll not made by powerbasic
« Reply #1 on: August 13, 2011, 10:44:31 AM »
Paul, perhaps this will help:

Code: [Select]
'-------------------------------------------------------------------------------------------------------
'  FUNCTION CheckExeForAttachedFile
'-------------------------------------------------------------------------------------------------------
FUNCTION CheckExecutableForAttachedFile(BYVAL sFile AS STRING) AS LONG
   'INPUT:  sFile = Name der Zieldatei
   'Funktionswert:  Art der Datei (DOS, 16Bit, Windows oder Konsolenprogramm
   LOCAL x AS SHFILEINFO
   LOCAL wD AS DWORD
   FUNCTION = 0
   wD = SHGETFILEINFO(BYVAL STRPTR(sFile), 0, x, SIZEOF(x), %SHGFI_EXETYPE)
   LOCAL wptr AS WORD PTR
   wptr = VARPTR(wD)
   SELECT CASE MKWRD$(@wptr[0])
      CASE "MZ"
         IF MKWRD$(@wptr[1]) = CHR$(0, 0) THEN
            FUNCTION = %EXE_DOS
         END IF
      CASE "NE"
         SELECT CASE MKWRD$(@wptr[1])
            CASE CHR$(0, 3), CHR$(5, 3), CHR$(0, 4)
               FUNCTION = %EXE_16BIT
         END SELECT
      CASE "PE"
         SELECT CASE MKWRD$(@wptr[1])
            CASE CHR$(0, 3), CHR$(5, 3), CHR$(0, 4)
               FUNCTION = %EXE_WINDOWS
            CASE CHR$(0, 0)
               FUNCTION = %EXE_CONSOLE
         END SELECT
      CASE ELSE
   END SELECT
END FUNCTION

'-------------------------------------------------------------------------------------------------------
'  FUNCTION LoadAttachedFile:
'     Attaches files after EOF of the compiled module (DLL, EXE)         
'     Syntax:
'              LoadAttachedFile PATH ALIAS Alias_Name                                   
'     Example:                                                             
'              LoadAttachedFile "C:\ZlbDir\zlib.dll" ALIAS "zlib 1.14"               
'     sAlias:
'              Used in run-time inside LoadAttachedFile functions.
'     FileOut:
'              Output FileName         
'-------------------------------------------------------------------------------------------------------
FUNCTION LoadAttachedFile(BYVAL vt AS VARIANT, BYVAL sAlias AS STRING, sFileOut AS STRING) AS LONG
   'INPUT  vt:       %VT_BSTR = dynamic Unicode string
   '                 %VT_R8   = Floating Point Double
   '       sAlias:   Name der Exe/Dll mit der Ressource
   '       sFileOut: Name der Ausgabedatei
   'Funktionswert:   Fehlerausgabe 0 = OK
   LOCAL szFile AS ASCIIZ * %MAX_PATH
   LOCAL sTemp AS STRING
   LOCAL hInstTemp AS DWORD
   LOCAL lpImageDosHeader AS IMAGE_DOS_HEADER PTR
   LOCAL lpImageNtHeaders AS IMAGE_NT_HEADERS PTR
   LOCAL lpImageSectionHeader AS IMAGE_SECTION_HEADER PTR
   LOCAL x1 AS IMAGE_DOS_HEADER
   LOCAL x2 AS IMAGE_NT_HEADERS
   LOCAL hFile AS LONG
   LOCAL L AS LONG
   LOCAL S AS STRING
   LOCAL W AS WORD
   LOCAL D AS DWORD
   LOCAL D1 AS DWORD
   LOCAL aptr AS ASCIIZ PTR

   FUNCTION = 0
   sFileOut = ""
   SELECT CASE VARIANTVT(vt)
      CASE %VT_BSTR
         sTemp = VARIANT$(vt)
         szFile = sTemp
      CASE %VT_R8
         hInstTemp = VARIANT#(vt)
         GetModuleFileName hInstTemp, szFile, %MAX_PATH
      CASE ELSE
         EXIT FUNCTION
   END SELECT
   TRY
      L = GETATTR(szFile)
   CATCH
      EXIT FUNCTION
   END TRY
   sAlias = UCASE$(sAlias)
   hFile = FREEFILE
   OPEN szFile FOR BINARY ACCESS READ LOCK SHARED AS #hFile
   GET #hFile,,x1
   IF MKWRD$(x1.e_magic) <> "MZ" THEN
      CLOSE #hFile
      EXIT FUNCTION
   END IF
   IF x1.e_lfanew => LOF(hFile) THEN
      CLOSE #hFile
      EXIT FUNCTION
   END IF
   SEEK #hFile, x1.e_lfanew + 1
   GET #hFile, , x2
   CLOSE #hFile
   W = BITS??(x2.Signature)
   IF MKWRD$(W) <> "PE" THEN EXIT FUNCTION
   hFile = FREEFILE
   OPEN szFile FOR BINARY ACCESS READ LOCK SHARED AS #hFile
   GET$ #hFile, LOF(hFile), S
   CLOSE #hFile
   lpImageDosHeader = STRPTR(S)
   lpImageNtHeaders = lpImageDosHeader + @lpImageDosHeader.e_lfanew
   lpImageSectionHeader = lpImageNtHeaders + SIZEOF(IMAGE_NT_HEADERS)
   D = lpImageSectionHeader - lpImageDosHeader + SIZEOF(IMAGE_SECTION_HEADER) * @lpImageNtHeaders.FileHeader.NumberOfSections
   FOR D1 = 0 TO @lpImageNtHeaders.FileHeader.NumberOfSections - 1
      D = MAX(D, @lpImageSectionHeader[D1].PointerToRawData + @lpImageSectionHeader[D1].SizeOfRawData)
   NEXT
   IF LEN(S) < D THEN EXIT FUNCTION
   IF LEN(S) = D THEN EXIT FUNCTION
   IF CVDWD(MID$(S, D + 1, 4)) <> 19900821 THEN EXIT FUNCTION
   D1 = CVDWD(MID$(S, D + 9, 4))
   REDIM offsets((D1 * 2) + 3) AS LOCAL DWORD AT (STRPTR(S) + D)
   aptr = STRPTR(S) + offsets(3)
   FOR D1 = 1 TO offsets(2)
     IF UCASE$(@aptr) = sAlias THEN
        sFileOut = MID$(S, offsets(offsets(2) + (D1 - 1) + 3) + 1, offsets(offsets(2) + D1 + 3) - offsets(offsets(2) + (D1 - 1) + 3))
        FUNCTION = -1
        EXIT FUNCTION
     END IF
     aptr = aptr + LEN(@aptr) + 1
   NEXT
END FUNCTION
« Last Edit: August 13, 2011, 10:48:12 AM by José Roca »
Ing.-Buero Doerre (IBD)
Dipl-Ing. TH Norbert Doerre
Elpenbachstr. 63 - 65
46119 Oberhausen,  Germany
Technical Hard- and Software
Computer Forensic

Offline Paul Breen

  • Newbie
  • *
  • Posts: 39
  • User-Rate: +1/-10
Re: Resource dll not made by powerbasic
« Reply #2 on: September 17, 2011, 08:10:56 PM »
thanks, I will have to study this to figure it out. Although I don't need the 3rd party resource compiler  this brings up issues about dll's that I don't understand as well as I should.
Paul Breen