View Full Version : [Visual Basic] Memory Mapping sample
ADDiCT
11-28-2003, 06:47 AM
Sample code that allows u to communicate with ioFTPD from your VB5/6 program, through memory mapping.
Currently implemented: list online users
getting info from userfiles
kicking users on UID/CID
id2name & name2id (both groups & users)
Not yet implemented: Groupfiles
User&GroupIdTables
owner of a file (DC_VFS)
Remarks:
1. Get http://home.no.net/addict99/files/win3207.tlb.rar if u don't have it already. It's a reference file with alot of win32 api functions in declared. I have been using this one for years, it's very helpful.
Add it to any of your projects like this: Menu 'Project' -> 'References' -> (select the file)
2. Only usable on 5.2.11 and later.
3. Edit & use at own risk. Functions are all used in my sitewho.exe and i've never seen it crashing.
This thing is all about working with pointers & CopyMemory, if you don't know what u are doing, either your program or ioFTPD WILL crash at some point.
4. I'm not here to hold your hand, or teach you how to program in VB. I'm assuming u have advanced or expert knowledge/experience.
attachment removed, see below for updated samplecode.
SnypeTEST
11-28-2003, 12:47 PM
awsome thnx dude. now I can "Read" it.. lol :)
kraxdaz
11-28-2003, 01:30 PM
Big thx ADDiCT !
SnypeTEST
11-29-2003, 04:40 PM
EditTagline function.
add it to clsMemMap.cls
example:
mem.EditTagline 0, "NEW SHIT!"
there is a BUG IN VB (http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q179/1/40.asp&NoWebContent=1) so I had to make an extended function. I didnt want to mess with bytes. You can make many other functions out of this one like edit credits (to make a nuke.exe :)) , edit groups , blah blah blah
Public Function EditTagline(iUID As Integer, tagline As String) As Boolean
Dim lRet As Long
Dim lRet2 As Long
Dim lpUserFile As io_USERFILE
Dim ThisAllocation As mylpAllocation
'clear old data (if any)
'allocate shared memory
ThisAllocation = SharedAllocate(True, sizeof_USERFILE + (MAX_PATH * 2))
If (ThisAllocation.hDaemon = 0) Then
EditTagline = False
Exit Function
End If
'fill in structure
lpUserFile.Uid = iUID
'copy it to shared memory location
CopyMem2 ThisAllocation.lpMemory, lpUserFile, sizeof_USERFILE
'get the userfile from ioFTPD
lRet = QueryDaemon(DC_USERFILE_OPEN, ThisAllocation, 5000)
If lRet = 0 Then
lRet = QueryDaemon(DC_USERFILE_LOCK, ThisAllocation, 5000)
'ok !
EditTagline = True
'copy shared memory into structure
CopyMem1 lpUserFile, ThisAllocation.lpMemory, sizeof_USERFILE
lpUserFile.tagline = tagline
'edit tagline
Extended_EditUserFile ThisAllocation, lpUserFile
'close the userfile
lRet = QueryDaemon(DC_USERFILE_CLOSE, ThisAllocation, 5000)
Else
'user doesn't exist or function failed
EditTagline = False
End If
SharedFree ThisAllocation
End Function
Private Function Extended_EditUserFile(ThisAllocation As mylpAllocation, lpUserFile As io_USERFILE) As String
Dim lRet As Long
'copy shared memory into structure
CopyMem2 ThisAllocation.lpMemory, lpUserFile, sizeof_USERFILE
'unlock userfile
lRet = QueryDaemon(DC_USERFILE_UNLOCK, ThisAllocation, 5000)
'copy shared memory into structure
CopyMem1 lpUserFile, ThisAllocation.lpMemory, sizeof_USERFILE
End Function
I had probs porting datacopy.c , ( to return file owner/group ) maybe someone else wants to give it a try.
Topper
01-04-2004, 10:13 AM
Hi
Your Code works great. But in which format ist LastOnlineUser.lngIdleTime and LoginTime?
It´s only a number how can i change this to a time.
ADDiCT
01-04-2004, 10:44 AM
those are both unix timestamps (= total number of seconds that have passed since January 1, 1970)
try some sample code at PSCode.com to convert it to other forms of time/date:
http://www.pscode.com/vb/scripts/BrowseCategoryOrSearchResults.asp?blnWorldDropDown Used=TRUE&txtMaxNumberOfEntriesPerPage=10&blnResetAllVariables=TRUE&txtCriteria=unix+time&lngWId=1&B1=Quick+Search&optSort=Alphabetical
When ioGui2 is "ready", i will update this thread with the ioGuiExt sourcecode.
That updated code gets UserIdTable & GroupIdTable, extracts all info from userfiles & groupfiles, changes a user's flags.
ADDiCT
02-10-2004, 04:31 PM
sourcecode of ioGuiExt.exe (from ioGui version 2.0.0)
new functions: FULL Userfiles
Groupfiles
UserIdTable
GroupIdTable
changing userflags (for example, easy to change other settings as wel)
attachment removed, see below for updated samplecode.
ADDiCT
02-23-2004, 06:44 PM
ioGuiExt 1.0.3 sourcecode available at: http://www.ioftpd.com/scripts/script.php?id=27
has an important fix that will prevent some crashes.
vBulletin® v3.8.11 Alpha 3, Copyright ©2000-2024, vBulletin Solutions, Inc.