Programming Need help with C/C++/Delphi? Ask here and make us all laugh. |
11-13-2003, 04:15 PM
|
#1
|
Disabled
FlashFXP Registered User ioFTPD Administrator
Join Date: Dec 2001
Posts: 2,230
|
DC_VFS Change!
Structure this message uses, will be changed in next version, to something that is easier to use
|
|
|
12-08-2003, 04:19 AM
|
#2
|
Member
Join Date: Feb 2003
Posts: 31
|
help
Hi, is this new structure?
Code:
typedef struct _DC_VFS
{
UINT32 Uid;
UINT32 Gid;
DWORD dwFileMode;
DWORD dwBuffer;
PBYTE pBuffer[1];
} DC_VFS, * LPDC_VFS;
and how it works?
where are old values? Do not necessary anymore?
When I use this structure for DC_VFS_READ I obtain {5261654, 0, 0, 1024, {NULL}}
I really haven't 5261654 users.
THX for anyhelp
Miky
|
|
|
12-08-2003, 07:44 AM
|
#3
|
Senior Member
FlashFXP Beta Tester ioFTPD Scripter
Join Date: Aug 2003
Posts: 517
|
i would also appreciate a small C++ usage example of the new structure, so i can easily convert it to VB
(now it's just guessing and trial&error for me)
|
|
|
12-08-2003, 08:01 AM
|
#4
|
Posse Member
Ultimate Scripter ioFTPD Administrator
Join Date: Dec 2002
Posts: 1,956
|
Code:
void getFileOwner(const char *complete_filename, char *user)
{
if (!initSharedMem(1024 + (strlen(complete_filename) + 1) + sizeof(DC_VFS))) {
strcpy(user,"nobody");
return;
}
lpMessage->dwIdentifier = DC_VFS_READ;
LPDC_VFS pFileInformation = (LPDC_VFS)lpMessage->lpContext;
lpContext = (LPVOID)((ULONG)lpMessage->lpContext + sizeof(DC_VFS));
strcpy((LPTSTR)pFileInformation->pBuffer,complete_filename);
dwReturn = SendMessage(hIoFTPD, WM_SHMEM, NULL, (LPARAM)hMemory);
if (!dwReturn) {
WaitForSingleObject(hEvent,10000);
int uid = pFileInformation->Uid;
if (pFileInformation->dwFileMode==0 || !resolveUidToName(uid,user))
strcpy(user,"nobody");
} else {
strcpy(user,"nobody");
}
closeSharedMem();
}
|
|
|
12-15-2003, 04:47 AM
|
#5
|
Member
Join Date: Feb 2003
Posts: 31
|
it's better but not enough
what is
DWORD dwFileMode;
DWORD dwBuffer;
?
when I insert foldername to pBuffer and want to write new owner and groupe ioftpd crash
can you post example for DC_VFS_WRITE too or explain new structute, because only from your example I figure out that pBuffer is for file(folder??)name
THX
|
|
|
12-15-2003, 04:53 AM
|
#6
|
Disabled
FlashFXP Registered User ioFTPD Administrator
Join Date: Dec 2001
Posts: 2,230
|
when writing, dwBuffer contains length of filename + additional length of directory context. Length of filename includes terminating null character. (Additional context may contain information such as, privacy information or symbolic link target)
|
|
|
12-15-2003, 05:08 AM
|
#7
|
Member
Join Date: Feb 2003
Posts: 31
|
thanks, works fine
|
|
|
12-15-2003, 06:35 AM
|
#8
|
Disabled
FlashFXP Registered User ioFTPD Administrator
Join Date: Dec 2001
Posts: 2,230
|
Here's commands for context handling.. it uses really simple format: |type|length|data|TCHAR null|
BOOL CreateFileContext(LPFILECONTEXT lpContext, LPFILECONTEXT lpSourceContext)
{
// Copy context
if (lpSourceContext &&
lpSourceContext->dwData)
{
lpContext->dwData = lpSourceContext->dwData;
lpContext->lpData = Allocate("FileContext", lpContext->dwData);
if (! lpContext->lpData) return FALSE;
CopyMemory(lpContext->lpData, lpSourceContext->lpData, lpContext->dwData);
}
else ZeroMemory(lpContext, sizeof(FILECONTEXT));
return TRUE;
}
BOOL InsertFileContext(LPFILECONTEXT lpContext, BYTE Item, LPVOID lpData, DWORD dwData)
{
LPVOID lpMemory;
DWORD dwSlack, dwMemory;
TCHAR pBuffer[1];
pBuffer[0] = _TEXT('\0');
// Remove existing context
dwSlack = lpContext->dwData;
DeleteFileContext(lpContext, Item);
dwSlack = (lpContext->dwData ? dwSlack - lpContext->dwData : 0);
// Allocate more memory
if (dwSlack < (dwData + sizeof(BYTE) + sizeof(UINT32) + sizeof(TCHAR)))
{
lpMemory = ReAllocate(lpContext->lpData, "FileContext",
lpContext->dwData + dwData + sizeof(BYTE) + sizeof(UINT32) + sizeof(TCHAR));
if (! lpMemory) ERROR_RETURN(ERROR_NOT_ENOUGH_MEMORY, FALSE);
lpContext->lpData = lpMemory;
}
dwMemory = dwData + sizeof(BYTE) + sizeof(UINT32) + sizeof(TCHAR);
// Copy new data
CopyMemory((LPVOID)((ULONG)lpContext->lpData + lpContext->dwData),
&Item, sizeof(BYTE));
lpContext->dwData += sizeof(BYTE);
CopyMemory((LPVOID)((ULONG)lpContext->lpData + lpContext->dwData),
&dwMemory, sizeof(UINT32));
lpContext->dwData += sizeof(UINT32);
CopyMemory((LPVOID)((ULONG)lpContext->lpData + lpContext->dwData),
lpData, dwData);
lpContext->dwData += dwData;
CopyMemory((LPVOID)((ULONG)lpContext->lpData + lpContext->dwData), pBuffer, sizeof(TCHAR));
lpContext->dwData += sizeof(TCHAR);
return TRUE;
}
BOOL FreeFileContext(LPFILECONTEXT lpContext)
{
BOOL bReturn;
bReturn = Free(lpContext->lpData);
lpContext->lpData = NULL;
lpContext->dwData = 0;
return bReturn;
}
BOOL DeleteFileContext(LPFILECONTEXT lpContext, BYTE Item)
{
LPVOID lpMemory;
DWORD dwMemory;
// Remove existing context
lpMemory = FindFileContext(Item, lpContext);
if (lpMemory)
{
dwMemory = ((PUINT32)lpMemory)[-1];
lpMemory = (LPVOID)((ULONG)lpMemory - sizeof(UINT32) - sizeof(BYTE));
MoveMemory(lpMemory,
(LPVOID)((ULONG)lpMemory + dwMemory),
((ULONG)lpContext->lpData + lpContext->dwData) - ((ULONG)lpMemory + dwMemory));
lpContext->dwData -= dwMemory;
}
return TRUE;
}
LPVOID FindFileContext(BYTE Item, LPFILECONTEXT lpContext)
{
LPBYTE lpOffset;
UINT32 Size;
// Seek through buffer
lpOffset = (LPBYTE)lpContext->lpData;
for (;(ULONG)lpOffset - (ULONG)lpContext->lpData < lpContext->dwData;lpOffset += Size)
{
// Size of entry
Size = ((PUINT32)&lpOffset[1])[0] + sizeof(BYTE) + sizeof(UINT32);
if (lpOffset[0] == Item) return &lpOffset[sizeof(BYTE) + sizeof(UINT)];
}
return NULL;
}
|
|
|
Thread Tools |
|
Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
dll error at startup
|
Joel |
General Discussion |
7 |
05-20-2005 01:52 PM |
All times are GMT -5. The time now is 11:36 AM.
|