Call send message function

Hello i do this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
static const wchar_t *lol=L"";

LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
    {
        if (!lstrcmpW(((LVITEMW*)lparam)->pszText, lol))//The lparam is a LVITEM* struct.
        {
            return 0;//we simply return 0 (and we do not call the real SendMessage function.
        }
        return 0;
    }
    return base.SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
}


But show me that base is not declared, however i always use base.sendmessage to send the message of the function i am calling.
Error:
1
2
3
4
Dynamic.cpp: In function 'LRESULT BSSSendMessageW(HWND, UINT, WPARAM, LPARAM)':
Dynamic.cpp:37:12: error: 'base' was not declared in this scope
     return base.SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
            ^~~~


How i can send this message usin windows api
Last edited on
Is base a static/global variable? Otherwise there's no way you could call its method from the function and that's what your error looks like.

If base is a class name and you want to use a method that's not necessarily tied with an object, try this:
 
return base::SendMessage(hwnd, msg, wparam, lparam);
Last edited on
I did so:
return baseSendMessage(hwnd, msg, wparam, lparam)

But now i want to call my function since my main. So the function that i put upside:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
static const wchar_t *lol=L"";

LRESULT WINAPI BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
    if ( msg == LVM_INSERTITEMW || msg == LVM_SETITEMW)//Intercepts LVM_INSERTITEM and LVM_SETITEM messages
    {
        if (!lstrcmpW(((LVITEMW*)lparam)->pszText, lol))//The lparam is a LVITEM* struct.
        {
            return 0;//we simply return 0 (and we do not call the real SendMessage function.
        }
        return 0;
    }
    return base.SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
}


My main:
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
    if (!Hook())//Hook "Writefoobar"
    {
        cout << "Hook failed" << endl;
        return 1;
    }
	BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
    //Writefoobar();//Standard call to Writefoobar, but instead, Hookedwritefoobar will be executed
    cout << "Press a key to exit" << endl;
    _getch();
    return 0;
}


The errors when i add BSSSendMessageW with arguments in main:
Dynamic.cpp: In function 'LRESULT BSSSendMessageW(HWND, UINT, WPARAM, LPARAM)':
Dynamic.cpp:36:12: error: 'base' has not been declared
return base::SendMessage(hwnd, msg, wparam, lparam);//Calls the real SendMessage function.
^~~~
Dynamic.cpp: In function 'int main()':
Dynamic.cpp:46:23: error: expected primary-expression before 'hwnd'
BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
^~~~
Dynamic.cpp:46:34: error: expected primary-expression before 'msg'
BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
^~~
Dynamic.cpp:46:46: error: expected primary-expression before 'wparam'
BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
^~~~~~
Dynamic.cpp:46:61: error: expected primary-expression before 'lparam'
BSSSendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
^~~~~~
Last edited on
Topic archived. No new replies allowed.