Results 1 to 4 of 4

Thread: [RESOLVED] GetProcAddress not finding function listed in export table

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,625

    Resolved [RESOLVED] GetProcAddress not finding function listed in export table

    I'm trying to track down a GUID Microsoft has hidden for seemingly no other reason than to make it impossible to use certain interfaces in VB.

    Microsoft provides this sample of how to get a pointer to it:

    Code:
        // Retrieve the IID_ITextServices interface identifier from Msftedit.dll. 
        IID* pIID_ITS = (IID*)(VOID*)GetProcAddress(hmodRichEdit, "IID_ITextServices");
    
        // Retrieve the ITextServices interface.    
        hr = pUnk->QueryInterface(*pIID_ITS, (void**)&pTextServices);
    Code:
    Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, ByVal lpProcName As LongPtr) As LongPtr
    Private Declare Function LoadLibraryW Lib "kernel32" (ByVal lpLibFileName As LongPtr) As LongPtr
    Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As LongPtr) As Long
    
    Private Sub Command1_Click()
        Dim hRichEd As LongPtr
        hRichEd = LoadLibraryW(StrPtr("msftedit.dll"))
        If hRichEd Then
            Dim lpProc As LongPtr
            lpProc = GetProcAddress(hRichEd, StrPtr("IID_ITextServices"))
            If lpProc Then
                Dim tIID As UUID
                CopyMemory tIID, ByVal lpProc, LenB(tIID)
                Text1.Text = "IID_ITextServices=" & GUIDToString(tIID)
            Else
                Debug.Print "no lpProc; hRichEdit=" & hRichEd
            End If
            FreeLibrary hRichEd
        Else
            Debug.Print "no hRichEd"
        End If
    End Sub
    Public Function GUIDToString(tg As UUID, Optional bBrack As Boolean = True) As String
    'StringFromGUID2 never works, even "working" code from vbaccelerator AND MSDN
    GUIDToString = Right$("00000000" & Hex$(tg.Data1), 8) & "-" & Right$("0000" & Hex$(tg.Data2), 4) & "-" & Right$("0000" & Hex$(tg.Data3), 4) & _
    "-" & Right$("00" & Hex$(CLng(tg.Data4(0))), 2) & Right$("00" & Hex$(CLng(tg.Data4(1))), 2) & "-" & Right$("00" & Hex$(CLng(tg.Data4(2))), 2) & _
    Right$("00" & Hex$(CLng(tg.Data4(3))), 2) & Right$("00" & Hex$(CLng(tg.Data4(4))), 2) & Right$("00" & Hex$(CLng(tg.Data4(5))), 2) & _
    Right$("00" & Hex$(CLng(tg.Data4(6))), 2) & Right$("00" & Hex$(CLng(tg.Data4(7))), 2)
    If bBrack Then GUIDToString = "{" & GUIDToString & "}"
    End Function
    I've checked and msftedit.dll does have IID_ITextServices listed in the function export table, but GetProcAddress is not finding it (lpProc = 0). Any ideas what I'm doing wrong? MS' sample code doesn't explain how it obtained hmodRichEdit, so I thought I'd use the fairly typical way of LoadLibrary.

    (Yes I know this particular GUID can be found online, but other ones in this DLL can't, and I'm using this for verification of method).

  2. #2

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,625

    Re: GetProcAddress not finding function listed in export table

    Ah I'm so used to APIs taking Unicode strings the lack of a W in [in] LPCSTR lpProcName didn't even register, thanks.

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: [RESOLVED] GetProcAddress not finding function listed in export table

    I ran into this same problem when I wrote this. GetProcAddress has no Unicode version. It's the weirdest thing.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width