Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. question related to drivers

question related to drivers

Scheduled Pinned Locked Moved C / C++ / MFC
question
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gamitech
    wrote on last edited by
    #1

    I have device driver and I want to write in a file from within the driver. I am using ZwCreateFile() ZwWriteFile() ZwClose() functions. When I call the InitializeObjectAttributesfunction() i do not know how should the object name look like. I mean if my file name is: D:\\status.txt or something like this: \Device\HarddiskVolume1\status.txt I want to ask now if these are the functions I should use when writting in a file from the kernel: Here is a piece of code. Can someone tell me what I do wrong? NTSTATUS WriteStatusInFile( IN PCWSTR FileName, IN HANDLE hProcessId ) { UNICODE_STRING ObjN; OBJECT_ATTRIBUTES ObjAttrib; UNICODE_STRING ObjName; IN HANDLE hFile; IN IO_STATUS_BLOCK StatBlock,WStatBlock; RtlInitUnicodeString(&ObjN,L"\\D:\\status.txt"); InitializeObjectAttributes(&ObjAttrib,&ObjN, OBJ_KERNEL_HANDLE , NULL, NULL); ZwCreateFile(&hFile, FILE_WRITE_DATA|FILE_APPEND_DATA, &ObjAttrib, &StatBlock, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_WRITE, FILE_CREATE |FILE_OPEN, FILE_SEQUENTIAL_ONLY, NULL, 0 ); ZwWriteFile( hFile, NULL, NULL, NULL, &WStatBlock, L"Process Created or Terminated\n", sizeof("Process Created or Terminated\n"), NULL, NULL ); ZwClose(hFile); return WStatBlock.Status; } Thanks in advance. gabby

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups