![]() |
RegGetKeySecurity
Hallo Zusammen,
leider ist es kein Delphi aber ich hoffe ihr könnt mir trotzdem helfen. Ich bin schon am verzweifeln! Ich möchte mit einem einfachen API Call "RegGetKeySecurity" die DACL vom gewünschten Schlüssel auslesen.
Delphi-Quellcode:
Was könnte da falsch sein?
.data
lpSubKey db "SOFTWARE\Classes\.7z\2",0 phkResult dd 0 pSecurityDescriptor SECURITY_DESCRIPTOR <> .code start: xor eax,eax push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_LOCAL_MACHINE call RegOpenKeyEx push sizeof pSecurityDescriptor <-- Ich vermute der Fehler liegt hier push offset pSecurityDescriptor push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity push phkResult call RegCloseKey @_ExitProcess: push 0 call ExitProcess end start Danke! Greatz |
Re: RegGetKeySecurity
Weißt du, wie es in C geht?
|
Re: RegGetKeySecurity
Hier ein Auszug aus MSDN.
http://msdn.microsoft.com/en-us/library/aa379313(VS.85).aspx Syntax RegGetKeySecurity(HKEY hKey,SECURITY_INFORMATION SecurityInformation,PSECURITY_DESCRIPTOR pSecurityDescriptor,LPDWORD lpcbSecurityDescriptor); Parameters hKey [in] A handle to an open key for which to retrieve the security descriptor. SecurityInformation [in] A SECURITY_INFORMATION value that indicates the requested security information. pSecurityDescriptor [out, optional] A pointer to a buffer that receives a copy of the requested security descriptor. lpcbSecurityDescriptor [in, out] A pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pSecurityDescriptor parameter. When the function returns, the variable contains the number of bytes written to the buffer. |
Re: RegGetKeySecurity
Delphi-Quellcode:
Der "SECURITY_DESCRIPTOR" gehört in die nicht initialisierte section. Jetzt ist nur noch die Frage wie ich diesen initialisiere vor der verwendung.
.data
lpSubKey db "SOFTWARE\Classes\.7z\2",0 phkResult dd 0 .data? pSecurityDescriptor SECURITY_DESCRIPTOR <> .code start: xor eax,eax push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_LOCAL_MACHINE call RegOpenKeyEx push sizeof SECURITY_DESCRIPTOR ;<-- Ich vermute der Fehler liegt hier push offset pSecurityDescriptor push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity push phkResult call RegCloseKey @_ExitProcess: push 0 call ExitProcess end start In der MSDN ( ![]() The SECURITY_DESCRIPTOR structure contains the security information associated with an object. Applications use this structure to set and query an object's security status. Because the internal format of a security descriptor can vary, we recommend that applications not modify the SECURITY_DESCRIPTOR structure directly. For creating and manipulating a security descriptor, use the functions listed in the See Also section. Vielleicht kann mir bei der initialisierung des SECURITY_DESCRIPTOR helfen. Viele Grüße :coder2: |
Re: RegGetKeySecurity
http://msdn.microsoft.com/en-us/library/aa378863(VS.85).aspx
Code:
pSecurityDescriptor [out]
BOOL WINAPI InitializeSecurityDescriptor(
__out PSECURITY_DESCRIPTOR pSecurityDescriptor, __in DWORD dwRevision ); A pointer to a SECURITY_DESCRIPTOR structure that the function initializes. dwRevision [in] The revision level to assign to the security descriptor. This parameter must be SECURITY_DESCRIPTOR_REVISION. ich hoffe das hilft |
Re: RegGetKeySecurity
Danke, genau das habe ich auch gerade gefunden.
Das Problem ist nur ich bekomme im CPU Register EAX 00000001 raus. EAX 00000001 <--- ECX 00403020 RegAth.00403020 EDX 00292CA0 EBX 7FFD9000 ESP 0012FF8C EBP 0012FF94 ESI 00000000 EDI 00000000 EIP 00401029 RegAth.00401029 C 0 ES 0023 32bit 0(FFFFFFFF) P 0 CS 001B 32bit 0(FFFFFFFF) A 0 SS 0023 32bit 0(FFFFFFFF) Z 0 DS 0023 32bit 0(FFFFFFFF) S 0 FS 003B 32bit 7FFDF000(FFF) T 0 GS 0000 NULL D 0 O 0 LastErr ERROR_SUCCESS (00000000) EFL 00000202 (NO,NB,NE,A,NS,PO,GE,G) ST0 empty 0.0 ST1 empty 0.0 ST2 empty 0.0 ST3 empty 0.0 ST4 empty 0.0 ST5 empty 0.0 ST6 empty 0.0 ST7 empty 0.0 3 2 1 0 E S P U O Z D I FST 0000 Cond 0 0 0 0 Err 0 0 0 0 0 0 0 0 (GT) FCW 027F Prec NEAR,53 Mask 1 1 1 1 1 1
Delphi-Quellcode:
.data
lpSubKey db "SOFTWARE\Classes\.7z\2",0 phkResult dd 0 .data? pSecurityDescriptor SECURITY_DESCRIPTOR <> .code start: xor eax,eax push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_LOCAL_MACHINE call RegOpenKeyEx push SECURITY_DESCRIPTOR_REVISION push offset pSecurityDescriptor call InitializeSecurityDescriptor push sizeof SECURITY_DESCRIPTOR ;<-- Ich vermute der Fehler liegt hier push offset pSecurityDescriptor push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity push phkResult call RegCloseKey @_ExitProcess: push 0 call ExitProcess end start |
Re: RegGetKeySecurity
hoi,
sorry ich hab absolut keine ahnung von asm :P Ich weis nich wie es mit dem Registry verhalten von windows ist aber wenn mit die Dacl's mit dateien verwendest musst du aufpassen ob du in einer domain bist oder nicht ... das is alles ein wenig undurchsichtig bzw ungeschickt. wenn du es so garnich hinbekommst mach es doch auf die, zugegeben unschoene, art dass du einfach versuchst etwas zu aendern, sollte das nicht klappen wirds wohl an den zugriffsrechten liegen. wenns klappt dann machste es wieder rueckgaenig. ich hab z.b. ueber die Dacl's versucht rauszufinden ob ich schreibrechte auf ne datei hab. kannste total erden. Ich hab keinen besseren weg als umbennen und bei bedarf wieder zurueck umbennen gefunden. cYa [edit] probier mal Software anstatt SOFTWARE [/edit] [edit2] ich mach das in C so: ( wie gesagt is mit dateien, is aber eigentlich gleich)
Code:
also erstmal anfragen und schauen wie gross der buffer sein muss und dann nochmal mit der richtigen groesse. vielleciht liegts bei dir da auch dran?
DWORD dwSizeNeeded=0;
AnsiString filePath=Edit1->Text; BYTE* pSecDescriptorBuf; pSecDescriptorBuf = new BYTE[1]; bool bSuccess = GetFileSecurity((filePath.c_str()),DACL_SECURITY_INFORMATION,pSecDescriptorBuf,1,&dwSizeNeeded); delete pSecDescriptorBuf; pSecDescriptorBuf = new BYTE[dwSizeNeeded]; bSuccess = GetFileSecurity((const_cast<char*>filePath.c_str()),DACL_SECURITY_INFORMATION,pSecDescriptorBuf,dwSizeNeeded,&dwSizeNeeded); |
Re: RegGetKeySecurity
Hey Volle!
Vielen Dank für deine Hilfe! Das mit dem DACL ist ein absoluter Müll! Bis ich das mal blicke,.... Das Problem ist, man findet dazu auch fast nichts im Internet oder zumindest nicht genug. Ich versuche jetzt ganz einfach mal das hier ![]() So wie es aussieht benötige ich die Größe schon bei der initialisierung vom SECURITY_DESCRIPTOR. Von den Rechten her ist es kein Thema,... Probiere es hin und wieder mit Systemrechten. Also Vollzugriff auf alles, daran lag es nicht. Komisches DACL,... :kotz: Grüßle |
Re: RegGetKeySecurity
Zitat:
![]() @ CoRe.eXtreem: Warum machst du das überhaupt alles mit ASM? |
Re: RegGetKeySecurity
vielleicht hilft dir das weiter:
![]() bist sicher das dwRevision die grösse sein soll? hoert sich fuer mich nich so an .. das is doch eher ne konstante oder? @luckie: bist du sicher dass das auch in ner domain geht, wenn die datei von einem domain user angelegt wurde und ein nicht domain user die rechte abfragen will? Hab grad leider kein delphi da und hab nich so arg lust das sinnloser weise in c++ zu portieren um dann festzustellendass es genauso wenig klappt wie bei mir :P |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:12 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz