如何限制 exe |
答題得分者是:pceyes
|
edens
一般會員 發表:2 回覆:7 積分:0 註冊:2008-10-13 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
主程式和子程式都是你寫的吧!
主程式用Shellexectue(handle, 'open', pchar('子程式.exe'),'使用者 密碼',nil,nil,shownormal); 子程式內容如下: procedure Tform1.OnCreate(Tobject:sender); begin if paramcount >= 2 then begin if (paramstr(1) <> '使用者') or (paramstr(2) <> '密碼') showmessage('沒有使用權限'); close; end; end else begin showmessage('參數不足'); close; end; end;
------
努力會更接近成功 |
edens
一般會員 發表:2 回覆:7 積分:0 註冊:2008-10-13 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
以下的案子和你的需求很像,而且相對,但你的達成可能比較高,內容好像有講到你要的方式。
Delphi K.Top討論區 » Object Pascal物件導向討論區(Delphi) » 如何限制 EXE 程式,只能被其它程式叫用 http://delphi.ktop.com.tw/board.php?cid=30&fid=70&tid=94146
------
努力會更接近成功 |
edens
一般會員 發表:2 回覆:7 積分:0 註冊:2008-10-13 發送簡訊給我 |
借用 rootkit 的代碼
function GetProcessParentID(PHandle: DWORD):DWORD; var Info : TProcessBasicInformation; begin Result := 0; if PHandle=0 then Exit; ZeroMemory(@info,SizeOf(info)); if NtQueryInformationProcess(PHandle, ProcessBasicInformation, @Info, sizeOf(Info), nil) = 0 then Result := Info.ParentPID; end 不過如果是要寫入 dll 中那 uses 底下要加入甚麼參數? |
RootKit
資深會員 發表:16 回覆:358 積分:419 註冊:2008-01-02 發送簡訊給我 |
自己補完:
[code delphi] type TProcessBasicInformation = record ExitStatus :Integer; PebBaseAddress :Pointer; AffinityMask :DWORD; BasePriority :Integer; PID :DWORD; ParentPID :DWORD; end; TNtProcessInfoClass = (ProcessBasicInformation, ProcessQuotaLimits, ProcessIoCounters, ProcessVmCounters, ProcessTimes, ProcessBasePriority, ProcessRaisePriority, ProcessDebugPort, ProcessExceptionPort, ProcessAccessToken, ProcessLdtInformation, ProcessLdtSize, ProcessDefaultHardErrorMode, ProcessIoPortHandlers, ProcessPooledUsageAndLimits, ProcessWorkingSetWatch, ProcessUserModeIOPL, ProcessEnableAlignmentFaultFixup, ProcessPriorityClass, MaxProcessInfoClass); TPDword = ^DWORD; var _NtQueryInformationProcess : function (ProcessHandle : DWORD; InfoClass : TNtProcessInfoClass; Buffer : Pointer; BufSize : DWORD; ReturnSize : TPDword) : DWORD; stdcall; Function NtQueryInformationProcess(ProcessHandle : DWORD; InfoClass : TNtProcessInfoClass; Buffer : Pointer; BufSize : DWORD; ReturnSize : TPDword) : DWORD; var NtDll: THandle; begin if not Assigned(_NtQueryInformationProcess) then begin NtDll := GetModuleHandle(PChar('ntdll.dll')); if NtDll <> 0 then _NtQueryInformationProcess := GetProcAddress(NtDll,'NtQueryInformationProcess'); end; if Assigned(_NtQueryInformationProcess) then Result := _NtQueryInformationProcess(ProcessHandle,InfoClass,Buffer,BufSize,ReturnSize) else Result := DWORD($C0000000); {ERROR_SEVERITY_ERROR 隨便帶一個錯誤 } end; [/code] |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |