C code to print the USB content - c

I am working in a UEFI environment and working with C code. To run a simple UEFI command I have to do it through C as shown below:
swprintf(
run_cmd,
wcslen(L"idrac1:\\Tools\\TCP_Recieve.efi")+wcslen(ipAddress)+1,
L"idrac1:\\Tools\\TCP_Recieve.efi %ls",
ipAddress
);
I need to know how to print the contents of the Pen Drive which is connected to my server using C code. I need something similar to 'ls' or 'dir' but for UEFI. Please help me with this.

The UEFI Shell source is available, which contains the source code for the ls command. It should give you enough information for what you need.
Download The EDKII UEFI Shell source.
Locate \ShellPkg\Library\UefiShellLevel2CommandsLib\Ls.c.

Related

DDD told me that there is no files named like "address"

I am training about a bare metal program as refer to one book.
So now, I execute debugging with "ddd" from ".axf" files which is output from "make".
There's something I'd like to ask about this ddd's error.
The picture described below is to be when I command "start".
They say, There are no file named "0x10210"
I have no idea but I think some libraries are failed to be called,which is necessary for executing this code.
What could I check for them?
I accomplished it by setting
target remote localhost:1234
before the start.

How to write my own code in NetSim?

I want to write my own custom code for Simulation in NetSim of www.tetcos.com.
I am a newbie to NetSim and can anyone explain me how to create new project ? Or just how do I printf to NetSim console ? Like a basic hello world type project ?
Here are three simple steps on how to start customization of code:
Step 1: Set up your project: Set your compiler such that your project code compiles into a Dynamic Link Library (DLL) in win (or Dynamic Shared Library (.so) in Linux).
Step 2: Copy source code: NetSim’s installation directory contains the source code for all protocols in folder $(NETSIM_INSTALL_DIR)/NetSim/Simulation/src . Copy paste the following files:
a. Header files related to TCP from the path $(NETSIM_INSTALL_DIR)/src/simulation/include
b. Lib files related to TCP from the path $(NETSIM_INSTALL_DIR)/src/simulation/lib
c. Source files related to TCP from the path $(NETSIM_INSTALL_DIR)/src/Simulation/tcp
Step 3: Modify code and replace the binary: Open TCP.c and write the Hello World print statement just after the TCP init function. Then build your code and replace the existing binary of NetSim (libTCP.dll or libTCP.so(for linux) in $(NETSIM_INSTALL_DIR)/NetSim/Simulation/bin) with your libTCP.dll(or libTCP.so).
Next, run a simulation you would see "Hello World" in command line.

draw call graph for C source codes using cppDepend

I have a problem with using cppDepend tool. I have a source code which is written in C language and I need to draw Its dependency or call graph. cppDepend's compiler's source code extension is set to c;cpp;cxx;cc but when I want to open source codes in C, the file chooser box only let me to choose source codes in C++.
What should I do????
In Linux? Why don't you use other options? Hast to be cppDepend? Look at cflow, callgrind (my favorite), or even gperf (which outputs a callgraph in graph form!)

Any mature solutions to create a instant shell with ELF symbols and c grammar command parser?

I need to make a debug shell inside each c exe(linux enviroment), and my solution is as follows:
Read elf symbols from exe file, build a symbol->address table in
memory;
Run a thread calling readline to accept user input, some thing
like a c function call;
use Lex & yacc to parse the function name and arg list;
Find address of the function in the symbol table;
Call the function with args list;
Every function written can be input as shell command instantly.
I don't think this is a fresh idea, and my question is: Are there any mature codes implemented already?
Thanks for your help!
Sure. If you had working with VxWorks, you'll find WindShell is what you're looking for. I had port a similar shell to Linux. You can download the source from:
https://sourceforge.net/projects/zprj/
Note: don't use the source in commercial products, since they are ported from WindShell. If you do want a shell in commercial fields, then you shall develop one with LEX/YACC.

How can a currently running C program find out what directory it is located in?

Say I have a command line C program which is currently executing, and I want to read a file or execute another binary in the same directory - how can I find out what directory that is?
Note that I'm not looking for the current working directory. The user may have invoked my original program in any of the following ways (and possibly others I don't know about).
../../program
/home/matt/program
PATH=$PATH:/home/matt program
Ideally I'm looking for something which will work on a unix system and windows via MinGW.
http://c-faq.com/osdep/exepath.html
According to the C FAQ it can't be done reliably
Finding current executable's path without /proc/self/exe
Concat getcwd() and dirname(argv[0])

Resources