Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change data in pagein hooked function #6

Open
sdhzdmzzl opened this issue Aug 28, 2018 · 1 comment
Open

how to change data in pagein hooked function #6

sdhzdmzzl opened this issue Aug 28, 2018 · 1 comment

Comments

@sdhzdmzzl
Copy link

Hi,slavaim:
I used this code to modify some data , read write rename truncate all works.
but I don't know how to modify data in pagein and pageout procedure.
my code like belows:
`int
FltVnopPageinHook(
__in struct vnop_pagein_args *ap
)

{
int (origVnop)(struct vnop_pagein_args ap);
origVnop = (int (
)(struct vnop_pagein_args
))FltGetOriginalVnodeOp( ap->a_vp, FltVopEnum_pagein );
assert( origVnop );

char procname[1024] ={0};
proc_selfname( procname, 1024);
int ret = origVnop( ap );
if(0 == strcmp("test", procname))
{
    char path[1024] = {0};
    int len = 1024;
    vn_getpath(ap->a_vp, path, &len);
    int flags =UPL_RET_ONLY_DIRTY;
    vm_offset_t map = NULL;
    vm_offset_t map1 = NULL;
    upl_t upl = NULL;
    upl_page_info_t* uplpageinfo = NULL;
    if(ap->a_flags&UPL_MSYNC)
    {
        flags = flags | UPL_UBC_MSYNC;
    }
    else{
        flags = flags | UPL_UBC_PAGEIN;
    }
    //ubc_create_upl(ap->a_vp, ap->a_f_offset, ap->a_size, &upl, &uplpageinfo, UPL_UBC_PAGEIN|UPL_RET_ONLY_ABSENT);
    ubc_create_upl(ap->a_vp, ap->a_f_offset, ap->a_size, &upl, &uplpageinfo, UPL_UBC_PAGEIN|UPL_FLAGS_NONE);
    //ubc_upl_map(ap->a_pl, &map);
    ubc_upl_map(upl, &map1);
    char *p = (char*)map1;
    *p = '5';
    if(map1)
    {
        ubc_upl_unmap(upl);
    }
    if(upl)
    {
        ubc_upl_commit(upl);
        //ubc_upl_abort_range(upl,  ap->a_f_offset, ap->a_size, UPL_ABORT_FREE_ON_EMPTY);
    }
}
return ret;

}
`
for example, If a text file which content is "aaaa", after hook pagein function, I want the user who view it to see its content as "5aaa",but above codes don't work.
thanks for your reply.

@kingfly629
Copy link

hey,sdhzdmzzl!
how do you solve this problem?
as i known , the action of read() may no trigger pagein()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants