FS Development - KMDF Windows Driver [closed] - windows

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new here and am trying to develop a concept fs driver for the tar 'filesystem' (mount tar). My question is, how does the OS detect that a partition has the TAR filesystem and automatically load my driver?

first of all loaded FS called IoRegisterFileSystem - this routine inserts the device object into the list of file systems in the system. then you must have a WRK. when say file opened on device with VPB IopCheckVpbMounted is called and he call IopMountVolume - this is key point for mount understand. this routine first walk through list with registered FS and send IRP_MN_MOUNT_VOLUME to all until some FS not return success code. also the last entry in the list - special File system recognizer - he try determinate format of the volume. and if yes - he return STATUS_FS_DRIVER_REQUIRED - indicates that need load new FS for this volume. system in this case call IopLoadFileSystemDriver. this routine is invoked when a mini-file system recognizer driver recognizes a volume as being a particular file system, but the driver for that file system has not yet been loaded. at the current moment FS_Rec.sys support next FS:
cdfs
ReFS
ReFSv1 // begin from win 10
ExFat
FastFat
Udfs
Ntfs
for support other - you need or auto load self FS driver or self recognizer (mini driver) which recognize your FS and return STATUS_FS_DRIVER_REQUIRED on IRP_MJ_FILE_SYSTEM_CONTROL.IRP_MN_MOUNT_VOLUME and load your FS (by ZwLoadDriver call ) on IRP_MJ_FILE_SYSTEM_CONTROL.IRP_MN_LOAD_FILE_SYSTEM

Related

is there an API to check if Mac's Microphone or video camera is in use? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Yes, I realize I can just look at the green-light when the video camera is on. That's not the point.
I'd like to write a little utility that notices when the mic or video camera is in use. I don't have any interest in knowing what app is using it. I just want to know if the mic / camera on or off.
This is for me as a parent. I was thinking I could get one of those color changing LED lights, and then when the camera/mic is on, my app could detect it, then send a signal to the light to change color. Then when one of my kids walks in, they'd see the light is "red" (meaning, do not disturb) and they'd know I'm on a conference call.
I have pretty much the exact same problem to solve. This is my prototype solution. It monitors the number of threads of the AppleCamera process. On the test macbook, the base number of threads seems to be 3. When an application uses the camera, the count increases to 4. I plan to implement microphone checking as well. I'm sure my code could be more compact and I could get the shell commands down to a one-liner but I prefer readability.
import subprocess
import pywemo
DEVICE_NAME = "BatSignal"
def count_camera_threads():
command = ["pgrep", "AppleCamera"]
process = subprocess.run(command, capture_output=True, text=True)
pid = process.stdout.replace("\n", "")
command = ["ps", "M", pid]
process = subprocess.run(command, capture_output=True, text=True)
lines = process.stdout
count = len(lines.splitlines()) - 2
return count
def get_device(name):
devices = pywemo.discover_devices()
for device in devices:
if device.name == name:
return device
return None
if __name__ == "__main__":
device = get_device(DEVICE_NAME)
if device is None:
exit(f"Unable to find '{DEVICE_NAME}' on network")
while True:
if count_camera_threads() > 3:
device.on()
else:
device.off()
time.sleep(1)

Creating beep sound in Windows [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to write a procedure that creates a beep sound on Windows, using assembly language.
How can I do that? Do you have any starting point idea?
In MS-DOS, which is what many assembly novices are targeting without even knowing it, outputting character ASCII 7 (BEL) via interrupt 21h, function AH=2 will do it:
mov ah, 2
mov dl, 7
int 21h
In Windows, call the MessageBeep() API function, passing 0xffffffff as the parameter. The function resides in User[32].dll; depending on your assembler, the sequence for importing an API function might vary.
If by "Windows" you mean "DOS executable running under Windows", which some people occasionally do, then back to int21h.

Get Volume GUID from Partition number in windows

I am looking for some kind help regarding below query.
I am trying to write (using WriteFile()) to a windows disk partition within a Windows PE environment by opening a disk handle and seeking to the partition starting offset.
WriteFile() is returning error code 5 (ACCESS DENIED).
I believe it is because the application has not locked the volume before writing to the volume.
My application has only the partition number as input. The ioctl FSCTL_LOCK_VOLUME needs a volume handle which is returned by CreateFile() and this needs a volume GUID as parameter.
So how do I get the volume GUID via the partition number?
Regards.

What may happen if sem_destroy() is not invoked on a semaphore in C? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
This is regarding to semaphore programming in C language.
sem_t mutex;
.
.
int main()
{
sem_init(&mutex, 0, 1);
.
.
.
.
sem_destroy(&mutex);
return 0;
}
If I do not use sem_destroy() at the last of my programs, what implications it may cause?
It is operating system specific. On Linux, read sem_overview(7); actually you are in an unspecified case. However, the documentation says
Before being used, an unnamed semaphore must be initialized
using sem_init(3). It can then be operated on using
sem_post(3) and sem_wait(3). When the semaphore is no longer
required, and before the memory in which it is located is
deallocated, the semaphore should be destroyed using
sem_destroy(3).
so you should call sem_destroy when appropriate; don't risk having a system-wide resource leak. BTW documentation of sem_destroy(3) tells:
An unnamed semaphore should be destroyed with sem_destroy() before
the memory in which it is located is deallocated. Failure to do this
can result in resource leaks on some implementations.
For named semaphores, things are different (they sit in /dev/shm/). I guess that a thread-shared semaphore might be destroyed when its memory segment is removed (no more mapped by any process). I am not sure of this and it is implementation specific behavior, so don't rely on this.
Use also proc(5).
So what may happen is a system-wide resource leak and you don't want it. You might need to reboot to remove it. BTW, you could use strace(1) to find out the actual syscalls involved, and you could look into the source code of your GNU glibc (or some other libc, like musl-libc) - and perhaps of the Linux kernel- to understand more the implementation specific behavior.
Avoid undefined behavior.
The address where Semaphore is stored will hold the last value of the semaphore if you dont use sem_destroy ...
It might cause problems as the semaphore's previous value might be indicating that a process is still running even if it is not !

Understanding dmesg messages [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am a newbie learning how to write Linux device drivers for USB devices. I want to understand the dmesg ouput
[ 6870.420077] usb 2-5: new low-speed USB device number 43 using ohci_hcd
[ 6870.500057] hub 2-0:1.0: unable to enumerate USB device on port 5
[ 6871.444057] usb 2-5: new low-speed USB device number 44 using ohci_hcd
[ 6871.524065] hub 2-0:1.0: unable to enumerate USB device on port 5
[ 6872.468089] usb 2-5: new low-speed USB device number 45 using ohci_hcd
[ 6872.548065] hub 2-0:1.0: unable to enumerate USB device on port 5
Could you direct me to some reading material explaining how to decipher these kernel messages?
dmesg - print or control the kernel ring buffer.
when dmesg command is issued, kernel ring buffer messages will be printed. There is no specific format used I guess.
Mostly whenever a new driver(or kernel code) is written, that particular module name is print first and corresponding message will be printed for differentiating our messages.
for example,
printk(KERN_ALERT "JayModule: Module loaded successfully.. ");
will print JayModule: Module loaded successfully.. in kernel ring buffer.
I guess numeric values given within [] is time.

Resources