I need to call an undocumented function called VaultRemoveItem(...) exported from a system dll vaultcli.dll. The problem is that I do not know the function prototype, and I haven't been able to find any information online.
Anyone has any suggestions on how I would go about discovering the arguments of the function? They are very likely to include pointers to some struct.
enum VAULT_SCHEMA_ELEMENT_ID {
ElementId_Illegal = 0x0,
ElementId_Resource = 0x1,
ElementId_Identity = 0x2,
ElementId_Authenticator = 0x3,
ElementId_Tag = 0x4,
ElementId_PackageSid = 0x5,
ElementId_AppStart = 0x64,
ElementId_AppEnd = 0x2710
};
enum VAULT_ELEMENT_TYPE {
ElementType_Undefined = 0xffffffff,
ElementType_Boolean = 0x0,
ElementType_Short = 0x1,
ElementType_UnsignedShort = 0x2,
ElementType_Integer = 0x3,
ElementType_UnsignedInteger = 0x4,
ElementType_Double = 0x5,
ElementType_Guid = 0x6,
ElementType_String = 0x7,
ElementType_ByteArray = 0x8,
ElementType_TimeStamp = 0x9,
ElementType_ProtectedArray = 0xa,
ElementType_Attribute = 0xb,
ElementType_Sid = 0xc,
ElementType_Last = 0xd
};
struct _VAULT_CAUB {
ULONG NumBytes;
UCHAR * pByteArray;
};
struct _ATTRIBUTE {
WCHAR * pszName;
ULONG dwFlags;
_VAULT_CAUB Value;
};
struct _VAULT_VARIANT {
VAULT_ELEMENT_TYPE Type;
union {
UCHAR Boolean;
SHORT Short;
USHORT UnsignedShort;
INT Int;
UINT UnsignedInt;
double Double;
_GUID Guid;
const WCHAR * String;
_VAULT_CAUB ByteArray;
_VAULT_CAUB ProtectedArray;
_ATTRIBUTE * Attribute;
PSID Sid;
};
};
struct _VAULT_ITEM_ELEMENT {
VAULT_SCHEMA_ELEMENT_ID SchemaElementId;
_VAULT_VARIANT ItemValue;
};
HRESULT WINAPI VaultOpenVault(const GUID* Store, ULONG Flags, PHANDLE phVault);
HRESULT WINAPI VaultRemoveItem(HANDLE hVault, const GUID* Schema, _VAULT_ITEM_ELEMENT* Resource, _VAULT_ITEM_ELEMENT* Identity, _VAULT_ITEM_ELEMENT* PackageSid OPTIONAL, PVOID OPTIONAL);
HRESULT WINAPI VaultCloseVault(HANDLE hVault);
void RemoveItem(PCWSTR url, PCWSTR login, PSID Sid = 0)
{
struct __declspec(uuid("3CCD5499-87A8-4B10-A215-608888DD3B55")) Vault_Schema_WebPassword;
struct __declspec(uuid("4BF4C442-9B8A-41A0-B380-DD4A704DDB28")) Vault_DefaultVault_ID;
HANDLE hVault;
if (!VaultOpenVault(&__uuidof(Vault_DefaultVault_ID), 0, &hVault))
{
_VAULT_ITEM_ELEMENT
Resource = {ElementId_Resource, ElementType_String },
Identity = {ElementId_Identity, ElementType_String },
PackageSid = {ElementId_PackageSid, ElementType_Sid };
Resource.ItemValue.String = url;
Identity.ItemValue.String = login;
PackageSid.ItemValue.Sid = Sid; // must be SECURITY_MANDATORY_LABEL_AUTHORITY or SECURITY_APP_PACKAGE_AUTHORITY
VaultRemoveItem(hVault, &__uuidof(Vault_Schema_WebPassword), &Resource, &Identity, &PackageSid(/* 0 */), 0);
VaultCloseVault(hVault);
}
}
Related
I'm setting up our private symbol server. Everything works great. Observe the following Resharper log when I debug into one of our Nuget packages using symbol server:
Searching for 'ClassLibrary1.Class1' type sources in C:\SNIPPED\SymbolCache\ClassLibrary1.pdb\91180103b9def6ca85f41230aaf9a4611\ClassLibrary1.pdb
Downloader: https ://LOCAL_SYMBOL_SVR/app/sources/builds/id-1641/sources/files/ClassLibrary1/Class1.cs -> ok, 268 bytes
See the hash, 91180103b9def6ca85f41230aaf9a4611? Notice that it is 33 digits.
I figured it might be stored in a PE header, but dumpbin.exe /all DLL doesn't contain the hash in its output.
Where does that hash come from? Is it stored within the DLL somewhere? If so, how and where is it stored?
if PE build with debug information - must exist IMAGE_DEBUG_DIRECTORY in it with IMAGE_DEBUG_TYPE_CODEVIEW. so first debugger search for array of IMAGE_DEBUG_DIRECTORY elements (it can be multiple). this array located at IMAGE_DIRECTORY_ENTRY_DEBUG data directory. for IMAGE_DEBUG_TYPE_CODEVIEW debug info now locate in format RSDS
struct RSDSI // RSDS debug info
{
DWORD dwSig; // RSDSI
GUID guidSig;
DWORD age;
char szPdb[];
};
the what you called "hash" this is really not hash formated from guidSig and age as %08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x
the dwSig must equal to 'SDSR' and szPdb stored as utf8 string
code example:
ULONG FormatPdbPath(PWSTR* ppdbPath, PCWSTR SymbolsPath, PCSTR PdbFileName, LPGUID Signature, DWORD Age)
{
ULONG UTF8StringByteCount = (ULONG)strlen(PdbFileName) + 1;
ULONG UnicodeStringLen = MultiByteToWideChar(CP_UTF8, 0, PdbFileName, UTF8StringByteCount, 0, 0);
if (!UnicodeStringLen)
{
return ERROR_GEN_FAILURE;
}
if (UnicodeStringLen >= MAXSHORT)
{
return ERROR_FILENAME_EXCED_RANGE;
}
PWSTR FileName = (PWSTR)alloca(UnicodeStringLen * sizeof(WCHAR));
UnicodeStringLen = MultiByteToWideChar(CP_UTF8, 0, PdbFileName, UTF8StringByteCount, FileName, UnicodeStringLen);
if (!UnicodeStringLen)
{
return ERROR_GEN_FAILURE;
}
if (PWSTR pdbPath = new WCHAR[2 * UnicodeStringLen + wcslen(SymbolsPath) + 42])
{
*ppdbPath = pdbPath;
swprintf(pdbPath, L"%s\\%s\\%08X%04X%04X%02X%02X%02X%02X%02X%02X%02X%02X%x\\%s",
SymbolsPath, FileName,
Signature->Data1, Signature->Data2, Signature->Data3,
Signature->Data4[0], Signature->Data4[1], Signature->Data4[2], Signature->Data4[3],
Signature->Data4[4], Signature->Data4[5], Signature->Data4[6], Signature->Data4[7],
Age, FileName);
return NOERROR;
}
return ERROR_NO_SYSTEM_RESOURCES;
}
ULONG FormatPdbPath(PWSTR* ppdbPath, PCWSTR SymbolsPath, PCWSTR lpszName)
{
HMODULE hmod = LoadLibraryExW(lpszName, 0, LOAD_LIBRARY_AS_DATAFILE);
if (!hmod) return GetLastError();
ULONG status = ERROR_NOT_FOUND;
DWORD cb;
BOOLEAN bMappedAsImage = !((DWORD_PTR)hmod & (PAGE_SIZE - 1));
PIMAGE_DEBUG_DIRECTORY pidd = (PIMAGE_DEBUG_DIRECTORY)RtlImageDirectoryEntryToData(hmod, bMappedAsImage, IMAGE_DIRECTORY_ENTRY_DEBUG, &cb);
if (pidd && cb && !(cb % sizeof(IMAGE_DEBUG_DIRECTORY)))
{
do
{
struct RSDSI // RSDS debug info
{
DWORD dwSig; // RSDSI
GUID guidSig;
DWORD age;
char szPdb[];
};
if (pidd->Type == IMAGE_DEBUG_TYPE_CODEVIEW && pidd->SizeOfData > sizeof(RSDSI))
{
if (DWORD PointerToRawData = bMappedAsImage ? pidd->AddressOfRawData : pidd->PointerToRawData)
{
RSDSI* lpcvh = (RSDSI*)RtlOffsetToPointer(PAGE_ALIGN(hmod), PointerToRawData);
if (lpcvh->dwSig == 'SDSR')
{
PCSTR szPdb = lpcvh->szPdb, c = strrchr(szPdb, L'\\');
if (c)
{
szPdb = c + 1;
}
status = FormatPdbPath(ppdbPath, SymbolsPath, szPdb, &lpcvh->guidSig, lpcvh->age);
break;
}
}
}
} while (pidd++, cb -= sizeof(IMAGE_DEBUG_DIRECTORY));
}
FreeLibrary(hmod);
return status;
}
void test(PCWSTR SymbolsPath, PCWSTR lpszName)
{
PWSTR pdbPath;
if (!FormatPdbPath(&pdbPath, SymbolsPath, lpszName))
{
DbgPrint("%S\n", pdbPath);
delete [] pdbPath;
}
}
void test2(PCWSTR SymbolsPath = L"C:\\SNIPPED\\SymbolCache")
{
WCHAR myExe[MAX_PATH];
GetModuleFileNameW(0, myExe, RTL_NUMBER_OF(myExe));
test(SymbolsPath, myExe);
test(SymbolsPath, L"hal.dll");
test(SymbolsPath, L"drivers/ntfs.sys");
test(SymbolsPath, L"kernel32.dll");
}
I connect to Arduino Uno R3 via a WinAPI handle.
std::string name = "COM5";
this->handle = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
How can I safely distinguish Arduino so I am not communicating with something different or at least get its name, preferably without third party libraries? After a research I found several APIs (QueryDosDevice and NtQueryObject), however I don't know how can I implement those in my code.
EDIT: I am now able to enumerate USB devices, however I have the exact opposite problem. I do not know how to CreateFile from these:
EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY DEVPKEY_Device_BusReportedDeviceDesc = { { 0x540b947e, 0x8b40, 0x45bc, { 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2 } }, 4 };
typedef BOOL(WINAPI *FN_SetupDiGetDeviceProperty)(
__in HDEVINFO DeviceInfoSet,
__in PSP_DEVINFO_DATA DeviceInfoData,
__in const DEVPROPKEY *PropertyKey,
__out DEVPROPTYPE *PropertyType,
__out_opt PBYTE PropertyBuffer,
__in DWORD PropertyBufferSize,
__out_opt PDWORD RequiredSize,
__in DWORD Flags
);
std::vector<device> usbenumerator::ListDevices()
{
DWORD dwSize;
DEVPROPTYPE ulPropertyType;
CONFIGRET status;
HDEVINFO hDevInfo;
SP_DEVINFO_DATA DeviceInfoData;
char szDeviceInstanceID[MAX_DEVICE_ID_LEN];
WCHAR szBuffer[4096];
FN_SetupDiGetDeviceProperty GetDeviceProperty = (FN_SetupDiGetDeviceProperty)(GetProcAddress(GetModuleHandle("setupapi.dll"), "SetupDiGetDevicePropertyW"));
hDevInfo = SetupDiGetClassDevs(NULL, "USB", NULL, DIGCF_ALLCLASSES | DIGCF_PRESENT);
std::vector<device> output;
if (hDevInfo == INVALID_HANDLE_VALUE)
{
return output;
}
for (int i = 0; ; i++)
{
device dev;
DeviceInfoData.cbSize = sizeof(DeviceInfoData);
if (!SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData))
{
break;
}
status = CM_Get_Device_ID(DeviceInfoData.DevInst, szDeviceInstanceID, MAX_PATH, 0);
if (status != CR_SUCCESS)
{
continue;
}
std::string deviceID = szDeviceInstanceID;
dev.id = deviceID;
if (GetDeviceProperty && GetDeviceProperty(hDevInfo, &DeviceInfoData, &DEVPKEY_Device_BusReportedDeviceDesc, &ulPropertyType, (BYTE*) szBuffer, sizeof(szBuffer), &dwSize, 0))
{
if (GetDeviceProperty(hDevInfo, &DeviceInfoData, &DEVPKEY_Device_BusReportedDeviceDesc, &ulPropertyType, (BYTE*)szBuffer, sizeof(szBuffer), &dwSize, 0))
{
_bstr_t b(szBuffer);
const char* cBusReportedDesc = b;
std::string busReportedDesc = cBusReportedDesc;
dev.busReportedDesc = busReportedDesc;
}
}
output.push_back(dev);
}
return output;
}
I think I got it: I am basically making my own copy of the SymbolicName key in the Windows registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\**YOUR_DEVICE_ID**\Device Parameters, for example HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\VID_2341&PID_0001\75633313233351E0A1E1\Device Parameters)
// Error checking omitted
CM_Get_Device_ID(DeviceInfoData.DevInst, szDeviceInstanceID, MAX_PATH, 0);
std::string deviceID = szDeviceInstanceID;
std::string did = deviceID;
// Convert all backslashes to hash signs
std::replace(did.begin(), did.end(), '\\', '#');
// The GUID seems to stay the same: https://learn.microsoft.com/en-us/windows-hardware/drivers/install/guid-devinterface-usb-device
std::string rid = "\\??\\" + did + "#{a5dcbf10-6530-11d2-901f-00c04fb951ed}";
handle = CreateFile(rid, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
I am attempting to PInvoke into the CCKeyDerivationPBKDF here.
The method signature looks like this:
int
CCKeyDerivationPBKDF( CCPBKDFAlgorithm algorithm, const char *password, size_t passwordLen,
const uint8_t *salt, size_t saltLen,
CCPseudoRandomAlgorithm prf, uint rounds,
uint8_t *derivedKey, size_t derivedKeyLen)
__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
Currently I am attempting this:
[DllImport(ObjCRuntime.Constants.libSystemLibrary, EntryPoint = "CCKeyDerivationPBKDF")]
public extern static void CCKeyCerivationPBKDF(int algorithm, string password, int passwordLen,
string salt, int saltLen, int prf, int rounds, out byte[] derivedKey, int derivedKeyLength);
and am getting the error:
malloc: *** error for object 0xb9374fc61e8f9d1e: pointer being freed was not allocated
This is my first attempt to PInvoke something. I'm fairly certain that my signature is probably way off. What does it need to be?
You are getting the pointer being freed was not allocated error due to the out flag on the derivedKey parameter, just pass it as an IntPtr (byte[]) and Mono will marshall it correctly:
CCKeyCerivationPBKDF signature:
[DllImport(ObjCRuntime.Constants.libSystemLibrary, EntryPoint = "CCKeyDerivationPBKDF")]
public extern static int CCKeyCerivationPBKDF(
int algorithm,
string password,
nint passwordLen,
string salt,
nint saltLen,
UInt32 prf,
int rounds,
byte[] derivedKey,
int derivedKeyLength);
Example:
var passwordEntry = "StackOverflow";
var saltEntry = "SaltyMcSalty";
var keyBytes = new byte[32 + 1];
Array.Clear(keyBytes, 0, keyBytes.Length);
var result = CCKeyCerivationPBKDF(2, passwordEntry, passwordEntry.Length, saltEntry, saltEntry.Length, 3, 1, keyBytes, keyBytes.Length);
Use "native" objects / reduced marshaling:
(Had to due it this way to get passed on a military/aerospace certification/review)
[DllImport(ObjCRuntime.Constants.libSystemLibrary, EntryPoint = "CCKeyDerivationPBKDF")]
public extern static int CCKeyCerivationPBKDF(
int algorithm,
IntPtr password,
nuint passwordLen,
IntPtr salt,
nuint saltLen,
UInt32 prf,
nuint rounds,
IntPtr derivedKey,
nuint derivedKeyLength);
Example (w/ Base64):
var passwordEntry = "StackOverflow";
var passwordBytes = System.Text.Encoding.UTF8.GetBytes(passwordEntry);
var passwordBase64 = Convert.ToBase64String(passwordBytes);
var passwordNSStringBase64 = new NSString(passwordBase64);
var passwordNSData = new NSData(passwordNSStringBase64, NSDataBase64DecodingOptions.None);
var saltEntry = "SaltyMcSalty";
var saltBytes = System.Text.Encoding.UTF8.GetBytes(saltEntry);
var saltBase64 = Convert.ToBase64String(saltBytes);
var saltNSStringBase64 = new NSString(saltBase64);
var saltNSData = new NSData(saltNSStringBase64, NSDataBase64DecodingOptions.None);
var keyBytes = new NSMutableData();
keyBytes.Length = 33;
var result = CCKeyCerivationPBKDF(2, passwordNSData.Bytes, passwordNSData.Length, saltNSData.Bytes, saltNSData.Length, 3, 1, keyBytes.MutableBytes, keyBytes.Length - 1);
As we all know,we can get eprocess address in win32 using the code below.
And this code works in user mode(ring 3).
#include <stdio.h>
#include <windows.h>
#define alloc(a) VirtualAlloc(0,a,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE)
#define freea(a) VirtualFree(a,0,MEM_RELEASE)
typedef struct {
PVOID Unknown1;
PVOID Unknown2;
PVOID Base;
ULONG Size;
ULONG Flags;
USHORT Index;
USHORT NameLength;
USHORT LoadCount;
USHORT PathLength;
CHAR ImageName[256];
} SYSTEM_MODULE_INFORMATION_ENTRY, *PSYSTEM_MODULE_INFORMATION_ENTRY;
typedef struct {
ULONG Count;
SYSTEM_MODULE_INFORMATION_ENTRY Module[1];
} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
typedef struct _SYSTEM_HANDLE
{
DWORD ProcessId;
// USHORT CreatorBackTraceIndex;
UCHAR ObjectTypeNumber;
UCHAR Flags;
USHORT Handle;
PVOID Object;
ACCESS_MASK GrantedAccess;
} SYSTEM_HANDLE, *PSYSTEM_HANDLE;
typedef struct _SYSTEM_HANDLE_INFORMATION
{
ULONG HandleCount; /* Or NumberOfHandles if you prefer. */
SYSTEM_HANDLE Handles[1];
} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemModuleInformation = 11,
SystemHandleInformation = 16
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *_NtQuerySystemInformation)(
SYSTEM_INFORMATION_CLASS SystemInformationClass,
PVOID SystemInformation,
ULONG SystemInformationLength,
PULONG ReturnLength
);
void main()
{
_NtQuerySystemInformation NtQuerySystemInformation=(_NtQuerySystemInformation)GetProcAddress(LoadLibrary(L"ntdll.dll"),"NtQuerySystemInformation");
PSYSTEM_MODULE_INFORMATION pmodinf;
PSYSTEM_HANDLE_INFORMATION phaninf;
ULONG len = 0;
char kname[260] = { 0 };
PVOID kbase = NULL;
DWORD cpid = GetCurrentProcessId();
HANDLE self = OpenProcess(PROCESS_QUERY_INFORMATION, NULL, cpid);
HANDLE self2 = NULL;
DuplicateHandle(GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(), &self2, NULL, NULL, NULL);
NtQuerySystemInformation(SystemModuleInformation, NULL, 0, &len);
pmodinf = (PSYSTEM_MODULE_INFORMATION)alloc(len);
RtlSecureZeroMemory(pmodinf, len);
NtQuerySystemInformation(SystemModuleInformation, pmodinf, len, &len);
lstrcpyA(kname, pmodinf->Module[0].ImageName);
kbase = pmodinf->Module[0].Base;
printf("kbase:%x\tkname:%s\n", kbase, kname);
HANDLE hntos = LoadLibraryA(kname);
len = 4096 * 16 * 16;
// NtQuerySystemInformation(SystemHandleInformation, NULL, 0, &len);
phaninf = (PSYSTEM_HANDLE_INFORMATION)alloc(len);
RtlSecureZeroMemory(phaninf, len);
NtQuerySystemInformation(SystemHandleInformation, phaninf, len, &len);
for (UINT i = 0; i < phaninf->HandleCount; i++)
{
if (phaninf->Handles[i].ProcessId==cpid)
{
printf("ObjectType:%d\n", phaninf->Handles[i].ObjectTypeNumber);
printf("Handle:%x,OpenProcessHandle:%x,DuplicateHandle:%x\n", phaninf->Handles[i].Handle, self,self2);
puts("");
if (phaninf->Handles[i].Handle==(USHORT)self)
{
puts("=============================");
printf("OpenProcessHandle\tEProcess Found!0x%x\n", phaninf->Handles[i].Object);
puts("=============================");
}
if (phaninf->Handles[i].Handle == (USHORT)self2)
{
puts("=============================");
printf("DuplicateHandle\tEProcess Found!0x%x\n", phaninf->Handles[i].Object);
puts("=============================");
}
}
}
freea(phaninf);
freea(pmodinf);
}
I want to get my process's EPROCESS address in winx64,but i failed. Do not use kernel function PsGetCurrrntProcess! I want my code works in user mode but kernel mode!
I am not able to allocate memory for nested structures using pointers.
What syntax should I use to allocate the memory for lots of structures that have pointers to other structures? How should I go about accessing the values in the structures once the memory is allocated?
struct A {
int *a;
struct B *b;
};
struct B {
int *b;
struct C *c;
};
struct C {
int *c;
struct D *d;
};
struct D {
int *d;
};
int main(int argc, const char* argv[]) {
struct A* foo;
/* Structure allocation */
/* use of structures */
}
I can't go beyond 2 nested structures. Beyond that I start getting Segmentation fault.
I tried something like this:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct file f1;
typedef struct command c1;
typedef struct arguments a1;
typedef struct ccity ccity;
typedef struct csub csub;
struct arguments {
char *argname;
struct arguments *next;
};
struct command {
char *cmdname;
struct arguments *args;
};
struct file{
int fileid;
char *filename;
struct command *cmd;
};
struct sub{
char *subname;
};
struct city {
char *city_name;
struct sub *s11;
};
struct road{
char *name;
struct city *next_city;
};
int main()
{
char name[] = "HELLO ";
struct file *f1;
struct city *c1 = NULL;
struct road *r1 = NULL;
struct sub *s1 = NULL;
printf("HELOOOOOOOOO");
f1->filename;
f1 = malloc(10*sizeof(struct file ));
f1->filename = (char *)malloc(10*sizeof(char *));
c1 = malloc(sizeof(c1));
r1 = malloc(sizeof(r1));
s1 = malloc(sizeof(s1));
r1->name = malloc(100*sizeof(char *));
r1->next_city = malloc(100*sizeof(r1->next_city));
c1->city_name = malloc(100*sizeof(char *));
c1->s11 = malloc(100*sizeof(c1->s11));
c1->s11->subname = calloc(120,sizeof(char*));
(*c1).s11->subname = "text";
(*r1).next_city->s11->subname =
malloc(10 * sizeof((*r1).next_city->s11->subname));
strncpy((*r1).next_city->s11->subname,"sant",4);
r1->name = malloc(sizeof(char *));
c1->city_name = malloc(sizeof(char *));
r1->next_city = malloc(sizeof(char *));
r1->next_city->city_name = "Hello";
/*strcpy(f1->filename,"file1");
printf("name is %s\n",(f1->filename));
c1->cmdname = (char *)malloc(10*sizeof(c1->cmdname));
strcpy(f1[0].cmd[0].cmdname,"command1");
printf("name is %s\n",f1[0].cmd[0].cmdname);
strcpy(f1[0].cmd[1].cmdname,"command2");
printf("name is %s\n",f1[0].cmd[1].cmdname);
strcpy(f1[0].cmd[2].cmdname,"command3");
printf("name is %s\n",f1[0].cmd[2].cmdname);
strcpy(f1[0].cmd[2].args[0].argname,"argument1");
printf("name is %s\n",f1[0].cmd[2].args[0].argname);
strcpy(f1[0].cmd[2].args[0].argname,"argument1");
printf("name is %s\n",f1[0].cmd[2].args[1].argname);
(f1[0].cmd[0].args[0]).argname = malloc(20*sizeof(char*));
strcpy((f1[0].cmd[0].args[0]).argname,"argument1");
printf("name is %s\n",(f1[0].cmd[0].args[0]).argname);
*/
}